| Conditions | 2 |
| Paths | 1 |
| Total Lines | 25 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | 4 | public function __invoke(): Closure |
|
| 22 | { |
||
| 23 | 4 | return |
|
| 24 | /** |
||
| 25 | * @param callable(mixed, mixed, iterable<TKey, T>): mixed ...$callbacks |
||
| 26 | */ |
||
| 27 | 4 | static fn (callable ...$callbacks): Closure => |
|
| 28 | /** |
||
| 29 | * @param iterable<TKey, T> $iterable |
||
| 30 | * |
||
| 31 | * @return Generator<mixed, mixed> |
||
| 32 | */ |
||
| 33 | 4 | static function (iterable $iterable) use ($callbacks): Generator { |
|
| 34 | 4 | $callbackFactory = |
|
| 35 | /** |
||
| 36 | * @return Closure(mixed, callable(mixed, mixed, iterable<TKey, T>): mixed): mixed |
||
| 37 | */ |
||
| 38 | 4 | static fn (mixed $key): Closure => |
|
| 39 | /** |
||
| 40 | * @param callable(mixed, mixed, iterable<TKey, T>): mixed $callback |
||
| 41 | */ |
||
| 42 | 4 | static fn (mixed $carry, callable $callback): mixed => $callback($carry, $key, $iterable); |
|
| 43 | |||
| 44 | 4 | foreach ($iterable as $key => $value) { |
|
| 45 | 4 | yield $key => array_reduce($callbacks, $callbackFactory($key), $value); |
|
| 46 | } |
||
| 50 |