MultipleOperation
class MultipleOperation
Allows to run a callable on each item of a collection.
Tracks the result of this operation:
- by default, the operation is successful
- if a call returns a falsy value, the operation is failed
- if all call returns truthy values, the operation is successful
That allows to run a multiple operation with a consolidate result answering the question "Were all calls successful?".
If a call fails, the subsequent calls still run.
Methods
No description
Applies the specified callable to each collection item.
Applies the specified callable to each collection item.
Determines if ALL the operations are successful so far
Details
at line 32
__construct(iterable $iterable)
No description
at line 53
static bool
do(iterable $iterable, callable $callable)
Applies the specified callable to each collection item.
The callable should return a boolean. If not, result will be converted to a boolean, which can lead to unexpected behavior.
The callable can has 0, 1 or 2 arguments:
- if it has one argument, it represents the value
- if it has two arguments, they represent (key, value)
The result of one operation is false if the calable returns a falsy value. The result of all operations are true if every callable returns a truthy value.
Returns if ALL the operation were successful.
at line 77
void
apply(callable $callable)
Applies the specified callable to each collection item.
The callable should return a boolean. If not, result will be converted to a boolean, which can lead to unexpected behavior.
The callable can has 0, 1 or 2 arguments:
- if it has one argument, it represents the value
- if it has two arguments, they represent (key, value)
Flips the global result to false if any of the callable returns a falsy value.
at line 100
bool
isOk()
Determines if ALL the operations are successful so far