Utils
in package
Utility static functions
Table of Contents
Methods
- call() : mixed
- Call object method
- callStatic() : mixed
- Call static method
- checkVersion() : bool
- Return true if required version = current or <
- cleanJson() : string
- Clean JSON text
- constant() : mixed
- Return constant value or default if constant not defined.
- convertPathToUrl() : string
- Convert path to url
- convertToBytes() : int|null
- Convert to bytes
- createKey() : string
- Create key
- createRandomKey() : string
- Create random key
- createToken() : string
- Create unique token
- formatVersion() : string
- Format version to full version format 0.0.0
- getBaseClassName() : string
- Return base class name
- getClasses() : array<string|int, mixed>
- Return classes from php code
- getDefault() : mixed
- Return default if variable is empty
- getExecutionTime() : float
- Get script execution time
- getMemorySizeText() : string|array<string|int, mixed>
- Get memory size text.
- getParentPath() : string|false
- Get parent path
- getValueAsText() : string
- Convert value to text
- hasHtml() : bool
- Check if text contains thml tags
- isClosure() : bool
- Return true if variable is Closure
- isEmail() : bool
- Return true if email is valid
- isEmpty() : bool
- Check if variable is empty
- isImplemented() : bool
- Check if class implement interface
- isJson() : bool
- Return true if text is valid JSON
- isUtf() : bool
- Return true if text is utf8 encoded string
- isValidIp() : bool
- Return true if ip is valid.
- isValidUrl() : bool
- Return true if url is valid
- jsonDecode() : array<string|int, mixed>
- Decode JSON text
- jsonEncode() : string|null
- Encode array to JSON
- removeBOM() : string
- Remove BOM from text
- slug() : string
- Create slug
Methods
call()
Call object method
public
static call(object $obj, string $method[, array<string|int, mixed>|null $args = null ]) : mixed
Parameters
- $obj : object
- $method : string
- $args : array<string|int, mixed>|null = null
callStatic()
Call static method
public
static callStatic(string $class, string $method[, array<string|int, mixed>|null $args = null ]) : mixed
Parameters
- $class : string
- $method : string
- $args : array<string|int, mixed>|null = null
checkVersion()
Return true if required version = current or <
public
static checkVersion(string $currentVersion, string $requiredVersion[, string|null $operator = null ]) : bool
Parameters
- $currentVersion : string
- $requiredVersion : string
- $operator : string|null = null
Return values
boolcleanJson()
Clean JSON text
public
static cleanJson(string $text) : string
Parameters
- $text : string
Return values
stringconstant()
Return constant value or default if constant not defined.
public
static constant(string $name[, mixed $default = null ]) : mixed
Parameters
- $name : string
- $default : mixed = null
convertPathToUrl()
Convert path to url
public
static convertPathToUrl(string $path) : string
Parameters
- $path : string
Return values
stringconvertToBytes()
Convert to bytes
public
static convertToBytes(string|int $size) : int|null
Parameters
- $size : string|int
Return values
int|nullcreateKey()
Create key
public
static createKey(string $text[, string $pathItem = null ][, string $separator = '.' ]) : string
Parameters
- $text : string
- $pathItem : string = null
- $separator : string = '.'
Return values
stringcreateRandomKey()
Create random key
public
static createRandomKey() : string
Return values
stringcreateToken()
Create unique token
public
static createToken([string $prefix = '' ][, bool $long = false ]) : string
Parameters
- $prefix : string = ''
- $long : bool = false
Return values
stringformatVersion()
Format version to full version format 0.0.0
public
static formatVersion(string|null $version) : string
Parameters
- $version : string|null
Return values
stringgetBaseClassName()
Return base class name
public
static getBaseClassName(string|object $class) : string
Parameters
- $class : string|object
Return values
stringgetClasses()
Return classes from php code
public
static getClasses(string $phpCode) : array<string|int, mixed>
Parameters
- $phpCode : string
Return values
array<string|int, mixed>getDefault()
Return default if variable is empty
public
getDefault(mixed $variable, mixed $default) : mixed
Parameters
- $variable : mixed
- $default : mixed
getExecutionTime()
Get script execution time
public
static getExecutionTime() : float
Return values
floatgetMemorySizeText()
Get memory size text.
public
static getMemorySizeText(int $size[, array<string|int, mixed> $labels = null ][, bool $asText = true ]) : string|array<string|int, mixed>
Parameters
- $size : int
- $labels : array<string|int, mixed> = null
- $asText : bool = true
Return values
string|array<string|int, mixed>getParentPath()
Get parent path
public
static getParentPath(string $path) : string|false
Parameters
- $path : string
Return values
string|falsegetValueAsText()
Convert value to text
public
static getValueAsText(mixed $value) : string
Parameters
- $value : mixed
Return values
stringhasHtml()
Check if text contains thml tags
public
static hasHtml(string $text) : bool
Parameters
- $text : string
Return values
boolisClosure()
Return true if variable is Closure
public
static isClosure(mixed $variable) : bool
Parameters
- $variable : mixed
Return values
boolisEmail()
Return true if email is valid
public
static isEmail(string $email) : bool
Parameters
- $email : string
Return values
boolisEmpty()
Check if variable is empty
public
static isEmpty(mixed $var) : bool
Parameters
- $var : mixed
Return values
boolisImplemented()
Check if class implement interface
public
static isImplemented(object $obj, string $interfaceName) : bool
Parameters
- $obj : object
- $interfaceName : string
Return values
boolisJson()
Return true if text is valid JSON
public
static isJson(string|null $jsonText) : bool
Parameters
- $jsonText : string|null
Return values
boolisUtf()
Return true if text is utf8 encoded string
public
static isUtf(mixed $text) : bool
Parameters
- $text : mixed
Return values
boolisValidIp()
Return true if ip is valid.
public
static isValidIp(string $ip) : bool
Parameters
- $ip : string
Return values
boolisValidUrl()
Return true if url is valid
public
static isValidUrl(string $url) : bool
Parameters
- $url : string
Return values
booljsonDecode()
Decode JSON text
public
static jsonDecode(string|null $text[, bool $clean = true ][, bool|null $associative = true ]) : array<string|int, mixed>
Parameters
- $text : string|null
- $clean : bool = true
- $associative : bool|null = true
Return values
array<string|int, mixed>jsonEncode()
Encode array to JSON
public
static jsonEncode(array<string|int, mixed>|null $data) : string|null
Parameters
- $data : array<string|int, mixed>|null
Return values
string|nullremoveBOM()
Remove BOM from text
public
static removeBOM(string $text) : string
Parameters
- $text : string
Return values
stringslug()
Create slug
public
static slug(string $text[, string $separator = '-' ]) : string
Parameters
- $text : string
- $separator : string = '-'