Utilities Class
Aurora\Helpers Namespace
Methods
debug
Show the value of a variable
Parameters
-
mixed
$var
— The variable to show -
string
$format
— Format to apply to the variable, only valid if $var is an array of strings
Signature
public function debug(mixed $var, string $format): void
convertBytes
Convert a shorthand byte value from a PHP configuration directive to an integer value
Parameters
-
mixed
$value
Return Value
int
Signature
public function convertBytes(mixed $value): int
formatBytes
Format a byte number using standard notation
Parameters
-
int
$bytes
— Number of bytes -
int
$precision
— Dot precision -
bool
$si
— Whether to use SI units or not
Return Value
string
Signature
public function formatBytes(int $bytes, int $precision = 2, bool $si = 1): string
getItem
Get an item from an array/object, or a default value if it's not set
Parameters
-
mixed
$var
— Array or object -
mixed
$key
— Key or index, depending on the array/object -
mixed
$default
— A default value to return if the item it's not in the array/object
Return Value
mixed
Signature
public function getItem(mixed $var, mixed $key, mixed $default = '')
getItemAt
Get an item from an array/object, or a default value if it's not set
Parameters
-
mixed
$var
— Array or object -
mixed
$key
— Key or index, depending on the array/object -
mixed
$default
— A default value to return if the item it's not in the array/object
Return Value
mixed
Signature
public function getItemAt(mixed $var, mixed $key, mixed $default = '')
optionSelected
Mark an option as selected by evaluating the variable
Parameters
-
mixed
$var
— Variable expected value -
mixed
$val
— Variable actual value -
string
$attr
— Attribute to use (selected, checked, etc) -
bool
$echo
— Whether to echo the result or not
Return Value
string
Signature
public function optionSelected(mixed $var, mixed $val, string $attr = 'selected', bool $echo = 1): string
base62Encode
Produce a base62 encoded string from a large binary number.
Parameters
-
string
$data
— Data to encode
Return Value
string
Signature
public function base62Encode(string $data): string
base62Decode
Produce a large binary number from a base62 encoded string.
Parameters
-
string
$encoded
— Data to decode
Return Value
string
Signature
public function base62Decode(string $encoded): string
divmod
Divide a large number represented as a binary string in the specified base and return the remainder.
Parameters
-
string
$binary
-
int
$base
-
int
$divisor
-
int
$start
Return Value
int
Signature
protected static function divmod(string &$binary, int $base, int $divisor, int $start): int
getUID
Generate a UID using system functions or a pseudo-random fallback
Return Value
string The UID
Signature
public function getUID(): string
randomToken
Generate a random token
Parameters
-
int
$length
— Length of the random token
Return Value
string
Signature
public function randomToken(int $length = 32): string
saltedToken
Salt a token
Parameters
-
string
$token
— Token to salt
Return Value
string
Signature
public function saltedToken(string $token): string
getGoogleFonts
Build a Google Fonts request string with the given fonts and styles
Parameters
-
array
$fonts
— An array with the desired fonts -
bool
$echo
— Whether to echo the result or not
Return Value
string
Signature
public function getGoogleFonts(array $fonts, bool $echo): string