FrostMVC\Functions
use FrostMVC\Functions;
General-purpose utility methods for the FrostMVC framework.
| ::Bush() | Obfuscates a string by interspersing random hex byte pairs between each character. A trailing random hex pair is appended. Intended for lightweight display obfuscation only — not a cryptographic or security mechanism. |
| ->call() | — |
| ::countries() | — |
| ::default() | Returns a default value when the given variable is null, empty, or absent from an array. |
| ::error() | Renders the standard error page with the given HTTP status and message. Terminates the current request via die(). |
| ::generateCaptcha() | Generates a random 7-character captcha code using an unambiguous character set (ambiguous characters like 0/O, 1/I are excluded). No character repeats. |
| ::generateOTP() | Generates a numeric OTP of the requested length. The first digit is never zero. Within the first five digits, no digit repeats. After the fifth digit, no digit is the same as the immediately preceding one. |
| ::generateToken() | Generates a cryptographically random alphanumeric token. |
| ::getErrorMessage() | Returns and clears the stored error message set by setErrorMessage(). |
| ::getMaxUploadSize() | Returns the smaller of the post_max_size and upload_max_filesize PHP INI values, in bytes. The result is computed once and cached in a static variable. |
| ::io_relocate() | Performs a client-side redirect by rendering the io_relocate Twig template. Terminates the current request via die(). |
| ::parse_size() | Parses a human-readable PHP INI size string (e.g. '8M', '256K', '1G') into bytes. |
| ::sendSMS() | — |
| ::setErrorMessage() | Stores a one-time error message to be retrieved with getErrorMessage(). Useful for passing validation errors through non-redirect flows. |
| ::ToByteUnit() | Converts a byte count into a human-readable string with the appropriate unit (bytes, KB, MB, or GB), rounded to 2 decimal places. |
| ::val() | Extracts a floating-point number from a string that may contain non-numeric characters. Retains digits, decimal point, sign characters (+/-), and hyphen. |
| ::writeLog() | — |
| ::xhrResult() | Emits a JSON response with an optional refreshed CSRF token and terminates the request. If $result is an array it is used directly as the response object; otherwise it is placed under the 'result' key alongside any $data fields. |
Functions::Bush($value)
Obfuscates a string by interspersing random hex byte pairs between each character. A trailing random hex pair is appended. Intended for lightweight display obfuscation only — not a cryptographic or security mechanism.
| $value | string |
The string to obfuscate. |
string
$functions->call($callback, ...$args)
No description yet.
| $callback | mixed |
|
| ...$args | mixed |
Functions::countries()
No description yet.
Functions::default($var, ...$params)
Returns a default value when the given variable is null, empty, or absent from an array.
Forms:
default($var, $fallback): returns $var, or $fallback when $var is null/empty string.default($array, 'key', $fallback): reads $array['key'], or $fallback on absence.default($var, 'callable', ...args): calls 'callable' with $var (and optional args) when $var is present. Use the '${value}' placeholder among args to control where $var is injected.| $var | mixed |
The value or array to inspect. |
| ...$params | mixed |
Fallback value, callable, or array key + fallback. |
mixed
Functions::error($message, $error = '', $code = 404, $title = 'Not Found', $uri = false)
Renders the standard error page with the given HTTP status and message. Terminates the current request via die().
| $message | string |
Human-readable error description. |
| $error | string |
Error title or type (shown in Development mode). Default:'' |
| $code | int |
HTTP status code. Defaults to 404. Default:404 |
| $title | string |
HTTP status phrase. Default:'Not Found' |
| $uri | string|false |
Optional URI context to include in the error view. Default:false |
Functions::generateCaptcha()
Generates a random 7-character captcha code using an unambiguous character set (ambiguous characters like 0/O, 1/I are excluded). No character repeats.
string
Functions::generateOTP($length = 8)
Generates a numeric OTP of the requested length. The first digit is never zero. Within the first five digits, no digit repeats. After the fifth digit, no digit is the same as the immediately preceding one.
| $length | int |
Number of digits. Defaults to 8. Default:8 |
string
Functions::generateToken($length)
Generates a cryptographically random alphanumeric token.
| $length | int |
The number of characters in the token. |
string
Functions::getErrorMessage()
Returns and clears the stored error message set by setErrorMessage().
string The message, or an empty string if none was set.
Functions::getMaxUploadSize()
Returns the smaller of the post_max_size and upload_max_filesize PHP INI values, in bytes. The result is computed once and cached in a static variable.
int Maximum upload size in bytes, or -1 if indeterminate.
Functions::io_relocate($url, $reload = false)
Performs a client-side redirect by rendering the io_relocate Twig template. Terminates the current request via die().
| $url | string |
The destination URL. |
| $reload | bool |
When true, signals the client that the current page should reload. Default:false |
Functions::parse_size($size)
Parses a human-readable PHP INI size string (e.g. '8M', '256K', '1G') into bytes.
| $size | string |
A value from ini_get(), such as '8M'. |
float The size in bytes.
Functions::sendSMS($phonenumber, $message)
No description yet.
| $phonenumber | mixed |
|
| $message | mixed |
Functions::setErrorMessage($message)
Stores a one-time error message to be retrieved with getErrorMessage(). Useful for passing validation errors through non-redirect flows.
| $message | string |
Functions::ToByteUnit($byte)
Converts a byte count into a human-readable string with the appropriate unit (bytes, KB, MB, or GB), rounded to 2 decimal places.
| $byte | int |
Size in bytes. |
string
Functions::val($string)
Extracts a floating-point number from a string that may contain non-numeric characters. Retains digits, decimal point, sign characters (+/-), and hyphen.
| $string | string |
The string to parse. |
float
Functions::writeLog($file, $value = false)
Use Logs::write() instead.
No description yet.
| $file | mixed |
|
| $value | mixed |
Default: false |
Functions::xhrResult($result, $data = [], $jsonFlag = JSON_INVALID_UTF8_SUBSTITUTE)
Emits a JSON response with an optional refreshed CSRF token and terminates the request. If $result is an array it is used directly as the response object; otherwise it is placed under the 'result' key alongside any $data fields.
| $result | mixed |
The primary result value, or an associative array used as the full response. |
| $data | mixed |
Additional key-value pairs to merge into the response, or a message string. Default:[] |
| $jsonFlag | int |
json_encode() flags. Defaults to JSON_INVALID_UTF8_SUBSTITUTE. Default:JSON_INVALID_UTF8_SUBSTITUTE |
Generated from core/classes/Functions.php (FrostMVC ).