Methods |
public
static
|
boolean(mixed $value): ($value is null ? null : bool)
Cast a value to boolean, converting boolean strings and preserving null
Cast a value to boolean, converting boolean strings and preserving null
|
#
|
public
static
|
integer(int|float|string|bool|null $value): ($value is null ? null : int)
Cast a value to integer, preserving null
Cast a value to integer, preserving null
|
#
|
public
static
|
arrayKey(int|string|null $value): ($value is null ? null : ($value is int ? int : int|string))
Cast a value to the array-key it appears to be, preserving null
Cast a value to the array-key it appears to be, preserving null
|
#
|
public
static
|
closure(?callable $callable): ($callable is null ? null : Closure)
Convert a callable to a closure
Convert a callable to a closure
|
#
|
public
static
|
value<T>((Closure(mixed...): T)|T $value, mixed ...$args): T
Resolve a closure to its return value
Resolve a closure to its return value
Parameters
...$args |
Passed to $value if it is a closure.
|
|
#
|
public
static
|
filter(string[] $values, bool $discardInvalid = false): mixed[]
Convert "key[=value]" pairs to an associative array
Convert "key[=value]" pairs to an associative array
|
#
|
public
static
|
coalesce<T>(T|null ...$values): T|null
Get the first value that is not null, or return the last value
Get the first value that is not null, or return the last value
|
#
|
public
static
|
array<TKey is array-key, TValue>(Arrayable<TKey, TValue>|iterable<TKey, TValue> $value): array<TKey, TValue>
Resolve a value to an array
Resolve a value to an array
|
#
|
public
static
|
list<TValue>(Arrayable<array-key, TValue>|iterable<TValue> $value): list<TValue>
Resolve a value to a list
Resolve a value to a list
|
#
|
public
static
|
count(Arrayable<array-key, mixed>|iterable<array-key, mixed>|Countable|int $value): int
Resolve a value to an item count
Resolve a value to an item count
|
#
|
public
static
|
basename(string $class, string ...$suffix): string
Get the unqualified name of a class, optionally removing a suffix
Get the unqualified name of a class, optionally removing a suffix
Only the first matching $suffix is removed, so longer suffixes should
be given first.
|
#
|
public
static
|
namespace(string $class): string
Get the namespace of a class
Get the namespace of a class
|
#
|
public
static
|
fqcn<T is object>(class-string<T> $class): class-string<T>
Normalise a class name for comparison
Normalise a class name for comparison
|
#
|
public
static
|
binaryUuid(?string $uuid = null): string
Get a UUID in raw binary form
Get a UUID in raw binary form
If $uuid is not given, an [RFC4122]-compliant UUID is generated.
Throws
|
#
|
public
static
|
uuid(?string $uuid = null): string
Get a UUID in hexadecimal form
Get a UUID in hexadecimal form
If $uuid is not given, an [RFC4122]-compliant UUID is generated.
Throws
|
#
|
public
static
|
randomText(int $length, string $chars = Str::ALPHANUMERIC): string
Get a sequence of random characters
Get a sequence of random characters
|
#
|
public
static
|
binaryHash(int|float|string|bool|Stringable|null $value): string
Get the hash of a value in raw binary form
Get the hash of a value in raw binary form
|
#
|
public
static
|
hash(int|float|string|bool|Stringable|null $value): string
Get the hash of a value in hexadecimal form
Get the hash of a value in hexadecimal form
|
#
|
public
static
|
type(mixed $value): string
Get the type of a variable
Get the type of a variable
|
#
|
public
static
|
bytes(string $size): int
Get php.ini values like "128M" in bytes
Get php.ini values like "128M" in bytes
From the PHP FAQ: "The available options are K (for Kilobytes), M (for
Megabytes) and G (for Gigabytes), and are all case-insensitive. Anything
else assumes bytes. 1M equals one Megabyte or 1048576 bytes. 1K equals
one Kilobyte or 1024 bytes."
|
#
|
public
static
|
code(
mixed $value,
string $delimiter = ', ',
string $arrow = ' => ',
?string $escapeCharacters = null,
string $tab = ' ',
string[] $classes = [],
array<non-empty-string, string> $constants = [],
): string
Convert a value to PHP code
Convert a value to PHP code
Similar to {@see var_export()}, but with more economical output.
Parameters
$classes |
Strings found in this array are output as
<string>::class instead of '<string>' .
|
$constants |
An array that maps
strings to constant identifiers, e.g. [\PHP_EOL => '\PHP_EOL'] .
|
|
#
|
public
static
|
eol(string $string): non-empty-string|null
Get the end-of-line sequence used in a string
Get the end-of-line sequence used in a string
Recognised line endings are LF ("\n" ), CRLF ("\r\n" ) and CR ("\r" ).
Returns
null if there are no recognised line
breaks in $string .
|
#
|
public
static
|
copy<T>(
T $value,
class-string[]|(Closure(object): (object|bool)) $skip = [],
int-mask-of<Get::COPY_*> $flags = Get::COPY_SKIP_UNCLONEABLE | Get::COPY_BY_REFERENCE,
): T
Get a deep copy of a value
Get a deep copy of a value
Parameters
$skip |
A list of
classes to skip, or a closure that returns:
-
true if the object should be skipped
-
false if the object should be copied normally, or
- a copy of the object
|
|
#
|