loophp /
collection
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace loophp\collection\Utils; |
||
| 6 | |||
| 7 | use Closure; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @internal |
||
| 11 | * |
||
| 12 | * @immutable |
||
| 13 | */ |
||
| 14 | final class CallbacksArrayReducer |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @return Closure(array<array-key, callable(mixed...): bool>): Closure(mixed...): bool |
||
| 18 | */ |
||
| 19 | 360 | public static function or(): Closure |
|
| 20 | { |
||
| 21 | 360 | return |
|
| 22 | /** |
||
| 23 | * @param array<array-key, callable(mixed...): bool> $callbacks |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 24 | * |
||
| 25 | * @return Closure(mixed...): bool |
||
| 26 | */ |
||
| 27 | 360 | static fn (array $callbacks): Closure => static fn (mixed ...$parameters): bool => array_reduce( |
|
| 28 | 360 | $callbacks, |
|
| 29 | /** |
||
| 30 | * @param callable(mixed...): bool $callable |
||
| 31 | */ |
||
| 32 | 360 | static fn (bool $carry, callable $callable): bool => $carry || $callable(...$parameters), |
|
| 33 | 360 | false |
|
| 34 | 360 | ); |
|
| 35 | } |
||
| 36 | } |
||
| 37 |