Documentation

Utils extends Helper
in package

Class Utils

Table of Contents

$app  : App
__call()  : mixed
__construct()  : mixed
__get()  : mixed
__invoke()  : mixed
buildTree()  : mixed
buildTreeList()  : mixed
fixRelativeUrls()  : mixed
fixStringBooleanValues()  : mixed
Cast boolean string values to boolean
fixStringNumericValues()  : mixed
Cast numeric string values to numbers
formatSize()  : string
getBearerToken()  : mixed
get access token from header
getMaxUploadSize()  : int
Return max upload size
gravatar()  : string
initialize()  : mixed
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
safe_truncate()  : string
Truncate a string to a specified length without cutting a word off.
sluggify()  : mixed|string
str_to_bool()  : bool
Converts many english words that equate to true or false to boolean.
url_get_contents()  : 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

Properties

Methods

__call()

public __call(mixed $name, mixed $arguments) : mixed
Parameters
$name : mixed
$arguments : mixed
Return values
mixed

__construct()

public __construct(mixed $app) : mixed
Parameters
$app : mixed
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[, mixed $options = [] ][, mixed $parentId = null ]) : mixed
Parameters
$elements : array<string|int, mixed>
$options : mixed = []
$parentId : mixed = null
Return values
mixed

buildTreeList()

public buildTreeList(mixed $items[, mixed $options = [] ][, mixed $parent = null ][, mixed $result = null ], mixed $depth[, mixed $path = '-' ]) : mixed
Parameters
$items : mixed
$options : mixed = []
$parent : mixed = null
$result : mixed = null
$depth : mixed
$path : mixed = '-'
Return values
mixed

fixRelativeUrls()

public fixRelativeUrls( $content[, string $base = '/' ]) : mixed
Parameters
$content :
$base : string = '/'
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
$size :
Return values
string

getBearerToken()

get access token from header

public getBearerToken() : mixed
Return values
mixed

getMaxUploadSize()

Return max upload size

public getMaxUploadSize() : int
Return values
int

gravatar()

public gravatar( $email[, int $size = 40 ]) : string
Parameters
$email :
$size : int = 40
Return values
string

initialize()

public initialize() : mixed
Return values
mixed

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: array( 'a' => array('b', 'c'), 'b' => array(), 'c' => array('b') )

a depends on b and c, c depends on b, and b depends on nobody in this case we would return array('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) : null
Parameters
$times : int
$fn : callable
Return values
null

safe_truncate()

Truncate a string to a specified length without cutting a word off.

public safe_truncate(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
$string :
$replacement : string = '-'
$tolower : bool|true = true
Return values
mixed|string

str_to_bool()

Converts many english words that equate to true or false to boolean.

public str_to_bool(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

url_get_contents()

Get content from url source.

public url_get_contents(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

Search results