class Helpers

Miscellaneous utilities.

Constants

IsWindows

Methods

static string
capture(callable $func)

No description

static string
getLastError()

Returns the last occurred PHP error or an empty string if no error occurred. Unlike error_get_last(), it is not affected by the PHP directive html_errors and always returns text, not HTML.

static mixed
falseToNull(mixed $value)

Converts false to null, does not change other values.

static int|float
clamp(int|float $value, int|float $min, int|float $max)

Returns value clamped to the inclusive range of min and max.

static string|null
getSuggestion(array $possibilities, string $value)

Finds the string from $possibilities most similar to $value using Levenshtein distance, or null if none is close enough.

static bool
compare(mixed $left, string $operator, mixed $right)

Compares two values in the same way that PHP does. Recognizes operators: >, >=, <, <=, =, ==, ===, !=, !==, <>

static array
splitClassName(string $name)

Splits a class name into namespace and short class name.

Details

at line 27
static string capture(callable $func)

No description

Parameters

callable $func

Return Value

string

at line 44
static string getLastError()

Returns the last occurred PHP error or an empty string if no error occurred. Unlike error_get_last(), it is not affected by the PHP directive html_errors and always returns text, not HTML.

Return Value

string

at line 56
static mixed falseToNull(mixed $value)

Converts false to null, does not change other values.

Parameters

mixed $value

Return Value

mixed

at line 66
static int|float clamp(int|float $value, int|float $min, int|float $max)

Returns value clamped to the inclusive range of min and max.

Parameters

int|float $value
int|float $min
int|float $max

Return Value

int|float

at line 80
static string|null getSuggestion(array $possibilities, string $value)

Finds the string from $possibilities most similar to $value using Levenshtein distance, or null if none is close enough.

Parameters

array $possibilities
string $value

Return Value

string|null

at line 99
static bool compare(mixed $left, string $operator, mixed $right)

Compares two values in the same way that PHP does. Recognizes operators: >, >=, <, <=, =, ==, ===, !=, !==, <>

Parameters

mixed $left
string $operator
mixed $right

Return Value

bool

at line 119
static array splitClassName(string $name)

Splits a class name into namespace and short class name.

Parameters

string $name

Return Value

array