Utils
class Utils
Utility static functions
Methods
Return true if required version = current or <
Return true if url is valid
Return classes from php code
Get parent path
Create random key
Create unique token
Return true if ip is valid.
Check if class implement interface
Return constant value or default if constant not defined.
Convert path to url
Return true if text is valid JSON
Encode array to JSON
Clean JSON text
Decode JSON text
Call static method
Call object method
Return true if email is valid
Check if text contains thml tags
Remove BOM from text
Check if variable is empty
Format version to full version format 0.0.0
Create key
Return default if variable is empty
Convert value to text
Return true if variable is Closure
Return true if text is utf8 encoded string
Create slug
Get memory size text.
Return base class name
Get script execution time
Details
at line 28
static bool
checkVersion(string $currentVersion, string $requiredVersion, string|null $operator = null)
Return true if required version = current or <
at line 46
static bool
isValidUrl(string $url)
Return true if url is valid
at line 57
static array
getClasses(string $phpCode)
Return classes from php code
at line 83
static string|false
getParentPath(string $path)
Get parent path
at line 98
static string
createRandomKey()
Create random key
at line 110
static string
createToken(string $prefix = '', bool $long = false)
Create unique token
at line 125
static bool
isValidIp(string $ip)
Return true if ip is valid.
at line 137
static bool
isImplemented(object $obj, string $interfaceName)
Check if class implement interface
at line 164
static mixed
constant(string $name, mixed $default = null)
Return constant value or default if constant not defined.
at line 175
static string
convertPathToUrl(string $path)
Convert path to url
at line 186
static bool
isJson(string|null $jsonText)
Return true if text is valid JSON
at line 206
static string
jsonEncode(array $data)
Encode array to JSON
at line 217
static string
cleanJson(string $text)
Clean JSON text
at line 238
static array
jsonDecode(string|null $text, bool $clean = true, bool|null $associative = true)
Decode JSON text
at line 256
static mixed
callStatic(string $class, string $method, array|null $args = null)
Call static method
at line 269
static mixed
call(object $obj, string|null $method, array|null $args = null)
Call object method
at line 294
static bool
isEmail(string $email)
Return true if email is valid
at line 305
static bool
hasHtml(string $text)
Check if text contains thml tags
at line 316
static string|null
removeBOM(string $text)
Remove BOM from text
at line 327
static bool
isEmpty(mixed $var)
Check if variable is empty
at line 338
static string
formatVersion(string|null $version)
Format version to full version format 0.0.0
at line 357
static string
createKey(string $text, string|null $pathItem = null, string $separator = '.')
Create key
at line 369
mixed
getDefault(mixed $variable, mixed $default)
Return default if variable is empty
at line 380
static string
getValueAsText(mixed $value)
Convert value to text
at line 398
static bool
isClosure(mixed $variable)
Return true if variable is Closure
at line 409
static bool
isUtf(mixed $text)
Return true if text is utf8 encoded string
at line 421
static string
slug(string $text, string $separator = '-')
Create slug
at line 445
static string|array
getMemorySizeText(integer $size, string|null $labels = null, bool $asText = true)
Get memory size text.
at line 461
static string
getBaseClassName(string|object $class)
Return base class name
at line 475
static int
getExecutionTime(string $constantName = 'APP_START_TIME')
Get script execution time