Utils
extends Helper
in package
Class Utils
Table of Contents
- $app : App
- $context : mixed
- __call() : mixed
- __construct() : mixed
- __get() : mixed
- __invoke() : mixed
- buildTree() : array<string|int, mixed>
- buildTreeList() : mixed
- fixRelativeUrls() : mixed
- fixStringBooleanValues() : mixed
- Cast boolean string values to boolean
- fixStringNumericValues() : mixed
- Cast numeric string values to numbers
- formatSize() : string
- getMaxUploadSize() : int
- Return max upload size
- isEmail() : bool
- Check if string is valid email
- parseSize() : void
- Parse size string
- resolveDependencies() : array<string|int, mixed>
- resolves complicated dependencies to determine what order something can run in
- retry() : null
- Execute callable with retry if it fails
- safeTruncate() : string
- Truncate a string to a specified length without cutting a word off.
- sluggify() : mixed|string
- strToBool() : bool
- Converts many english words that equate to true or false to boolean.
- urlGetContents() : string
- Get content from url source.
- var_export() : void
- var_export with bracket array notation source: https://www.php.net/manual/en/function.var-export.php#122853
- initialize() : mixed
Properties
$app
public
App
$app
$context
public
mixed
$context
Methods
__call()
public
__call(mixed $name, mixed $arguments) : mixed
Parameters
- $name : mixed
- $arguments : mixed
Return values
mixed —__construct()
public
__construct(App $app[, mixed $context = null ]) : mixed
Parameters
- $app : App
- $context : mixed = null
Return values
mixed —__get()
public
__get(mixed $name) : mixed
Parameters
- $name : mixed
Return values
mixed —__invoke()
public
__invoke(mixed $helper) : mixed
Parameters
- $helper : mixed
Return values
mixed —buildTree()
public
buildTree(array<string|int, mixed> $elements[, array<string|int, mixed> $options = [] ][, mixed $parentId = null ]) : array<string|int, mixed>
Parameters
- $elements : array<string|int, mixed>
- $options : array<string|int, mixed> = []
- $parentId : mixed = null
Return values
array<string|int, mixed> —buildTreeList()
public
buildTreeList(array<string|int, mixed> $items[, array<string|int, mixed> $options = [] ][, mixed $parent = null ][, mixed $result = null ], int $depth[, string $path = '-' ]) : mixed
Parameters
- $items : array<string|int, mixed>
- $options : array<string|int, mixed> = []
- $parent : mixed = null
- $result : mixed = null
- $depth : int
- $path : string = '-'
Return values
mixed —fixRelativeUrls()
public
fixRelativeUrls( $content[, string $base = '/' ]) : mixed
Parameters
Return values
mixed —fixStringBooleanValues()
Cast boolean string values to boolean
public
fixStringBooleanValues(mixed &$input) : mixed
Parameters
- $input : mixed
Return values
mixed —fixStringNumericValues()
Cast numeric string values to numbers
public
fixStringNumericValues(mixed &$input) : mixed
Parameters
- $input : mixed
Return values
mixed —formatSize()
public
formatSize( $size) : string
Parameters
Return values
string —getMaxUploadSize()
Return max upload size
public
getMaxUploadSize() : int
Return values
int —isEmail()
Check if string is valid email
public
isEmail(string $email) : bool
Parameters
- $email : string
Return values
bool —parseSize()
Parse size string
public
parseSize(string $size) : void
Parameters
- $size : string
Return values
void —resolveDependencies()
resolves complicated dependencies to determine what order something can run in
public
resolveDependencies(array<string|int, mixed> $data) : array<string|int, mixed>
start with an array like: [ 'a' => ['b', 'c'], 'b' => [], 'c' => ['b'] ]
a depends on b and c, c depends on b, and b depends on nobody in this case we would return ['b', 'c', 'a']
Parameters
- $data : array<string|int, mixed>
Return values
array<string|int, mixed> —retry()
Execute callable with retry if it fails
public
retry(int $times, callable $fn, int $delay) : null
Parameters
- $times : int
- $fn : callable
- $delay : int
Return values
null —safeTruncate()
Truncate a string to a specified length without cutting a word off.
public
safeTruncate(string $string, int $length[, string $append = '...' ]) : string
Parameters
- $string : string
-
The string to truncate
- $length : int
-
The length to truncate the string to
- $append : string = '...'
-
Text to append to the string IF it gets truncated, defaults to '...'
Return values
string —sluggify()
public
sluggify( $string[, string $replacement = '-' ][, bool|true $tolower = true ]) : mixed|string
Parameters
Return values
mixed|string —strToBool()
Converts many english words that equate to true or false to boolean.
public
strToBool(string $string[, bool $default = false ]) : bool
Supports 'y', 'n', 'yes', 'no' and a few other variations.
Parameters
- $string : string
-
The string to convert to boolean
- $default : bool = false
-
The value to return if we can't match any yes/no words
Return values
bool —urlGetContents()
Get content from url source.
public
urlGetContents(string $url) : string
Parameters
- $url : string
Return values
string —var_export()
var_export with bracket array notation source: https://www.php.net/manual/en/function.var-export.php#122853
public
var_export(mixed $expr[, bool $return = false ]) : void
Parameters
- $expr : mixed
- $return : bool = false
Return values
void —initialize()
protected
initialize() : mixed