| Conditions | 3 |
| Paths | 1 |
| Total Lines | 21 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | 118 | public function __invoke(): Closure |
|
| 23 | { |
||
| 24 | 118 | return |
|
| 25 | /** |
||
| 26 | * @param callable(int, T, TKey, iterable<TKey, T>): bool ...$predicates |
||
| 27 | * |
||
| 28 | * @return Closure(iterable<TKey, T>): Generator<int, bool> |
||
| 29 | */ |
||
| 30 | 118 | static fn (callable ...$predicates): Closure => static function (iterable $iterable) use ($predicates): Generator { |
|
| 31 | 118 | $predicate = CallbacksArrayReducer::or()($predicates); |
|
| 32 | |||
| 33 | /** @var Generator<int, array{0: TKey, 1:T}> $packed */ |
||
| 34 | 118 | $packed = (new Pack())()($iterable); |
|
| 35 | |||
| 36 | 118 | foreach ($packed as $index => [$key, $value]) { |
|
| 37 | 112 | if (false === $predicate($index, $value, $key, $iterable)) { |
|
| 38 | 78 | return yield $index => false; |
|
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | 84 | yield true; |
|
| 43 | 118 | }; |
|
| 46 |