Toolkit
in package
A convenience class wrapping various helper methods.
Table of Contents
- assert() : Assert
- Convenience methods for asserting the content of values.
- each() : void
- Pass each item in an iterable through a function.
- every() : bool
- Throw an $exception or return false if any of the provided values are null.
- filter() : Filter
- Convenience methods for filtering the content of values.
- merge() : array<string|int, mixed>
- Progressively merge one or more arrays, overwriting values from left to right. Null values is discarded.
- some() : array<string|int, mixed>|false
- Throw an $exception or return false if all the provided values are null.
- times() : void
- Run a function a certain number of times.
Methods
assert()
Convenience methods for asserting the content of values.
public
static assert(array<string|int, mixed> $subjects) : Assert
Parameters
- $subjects : array<string|int, mixed>
Return values
Assert —each()
Pass each item in an iterable through a function.
public
static each(iteratable<string|int, mixed> &$items, Closure $callback) : void
Parameters
- $items : iteratable<string|int, mixed>
-
the iterable to process
- $callback : Closure
-
the function to pass each item through
Return values
void —every()
Throw an $exception or return false if any of the provided values are null.
public
static every(Throwable|null $exception, array<string|int, mixed> $values) : bool
Parameters
- $exception : Throwable|null
-
an exception to throw if all values are null
- $values : array<string|int, mixed>
-
one or more values to check
Tags
Return values
bool —filter()
Convenience methods for filtering the content of values.
public
static filter(array<string|int, mixed> $subjects) : Filter
Parameters
- $subjects : array<string|int, mixed>
-
an array of values to work with
Return values
Filter —merge()
Progressively merge one or more arrays, overwriting values from left to right. Null values is discarded.
public
static merge(array<string|int, mixed>|null ...$arrays) : array<string|int, mixed>
Parameters
- $arrays : array<string|int, mixed>|null
-
one or more arrays to merge
Return values
array<string|int, mixed> —some()
Throw an $exception or return false if all the provided values are null.
public
static some(Throwable|null $exception, array<string|int, mixed> $values) : array<string|int, mixed>|false
Parameters
- $exception : Throwable|null
-
an exception to throw if all values are null
- $values : array<string|int, mixed>
-
one or more values to check
Tags
Return values
array<string|int, mixed>|false —times()
Run a function a certain number of times.
public
static times(int $times, Closure $callback) : void
Parameters
- $times : int
-
the number of times to run $callback
- $callback : Closure
-
the function to run