class Helpers

Methods

static string
capture(callable $func)

Executes a callback and returns the captured output as a string.

static string
getLastError()

Returns the last occurred PHP error or an empty string if no error occurred. Unlike error_get_last(), it is nit 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)

Looks for a string from possibilities that is most similar to value, but not the same (for 8-bit encoding).

static bool
compare(mixed $l, string $operator, mixed $r)

Compares two values. Recognizes operators: >, >=, <, <=, =, ==, ===, !=, !==, <>

Details

at line 20
static string capture(callable $func)

Executes a callback and returns the captured output as a string.

Parameters

callable $func

Return Value

string

at line 37
static string getLastError()

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

Return Value

string

at line 49
static mixed falseToNull(mixed $value)

Converts false to null, does not change other values.

Parameters

mixed $value

Return Value

mixed

at line 58
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 72
static string|null getSuggestion(array $possibilities, string $value)

Looks for a string from possibilities that is most similar to value, but not the same (for 8-bit encoding).

Parameters

array $possibilities
string $value

Return Value

string|null

at line 90
static bool compare(mixed $l, string $operator, mixed $r)

Compares two values. Recognizes operators: >, >=, <, <=, =, ==, ===, !=, !==, <>

Parameters

mixed $l
string $operator
mixed $r

Return Value

bool