| Conditions | 4 |
| Paths | 1 |
| Total Lines | 30 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | 6 | public function __invoke(): Closure |
|
| 23 | { |
||
| 24 | 6 | return |
|
| 25 | /** |
||
| 26 | * @param callable(T, TKey, iterable<TKey, T>):bool ...$callbacks |
||
| 27 | * |
||
| 28 | * @return Closure(iterable<TKey, T>): Generator<TKey, T> |
||
| 29 | */ |
||
| 30 | 6 | static fn (callable ...$callbacks): Closure => |
|
| 31 | /** |
||
| 32 | * @param iterable<TKey, T> $iterable |
||
| 33 | * |
||
| 34 | * @return Generator<TKey, T> |
||
| 35 | */ |
||
| 36 | 6 | static function (iterable $iterable) use ($callbacks): Generator { |
|
| 37 | 6 | $skip = false; |
|
| 38 | 6 | $callback = CallbacksArrayReducer::or()($callbacks); |
|
| 39 | |||
| 40 | 6 | foreach ($iterable as $key => $current) { |
|
| 41 | 6 | if (false === $skip) { |
|
| 42 | 6 | if (false === $callback($current, $key, $iterable)) { |
|
| 43 | 6 | $skip = true; |
|
| 44 | |||
| 45 | 6 | yield $key => $current; |
|
| 46 | } |
||
| 47 | |||
| 48 | 6 | continue; |
|
| 49 | } |
||
| 50 | |||
| 51 | 6 | yield $key => $current; |
|
| 52 | } |
||
| 56 |