| Conditions | 4 |
| Paths | 1 |
| Total Lines | 33 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 4 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | 36 | public function __invoke(): Closure |
|
| 20 | { |
||
| 21 | 36 | return |
|
| 22 | /** |
||
| 23 | * @param iterable<mixed, mixed> $other |
||
| 24 | * |
||
| 25 | * @return Closure(iterable<mixed, mixed>): Generator<int, bool, mixed, false|mixed> |
||
| 26 | */ |
||
| 27 | 36 | static fn (iterable $other): Closure => |
|
| 28 | /** |
||
| 29 | * @param iterable<mixed, mixed> $iterable |
||
| 30 | * |
||
| 31 | * @return Generator<int, bool, mixed, false|mixed> |
||
| 32 | */ |
||
| 33 | 36 | static function (iterable $iterable) use ($other): Generator { |
|
| 34 | 36 | $otherAggregate = new IterableIteratorAggregate($other); |
|
| 35 | 36 | $iteratorAggregate = new IterableIteratorAggregate($iterable); |
|
| 36 | |||
| 37 | 36 | $iterator = $iteratorAggregate->getIterator(); |
|
| 38 | 36 | $other = $otherAggregate->getIterator(); |
|
| 39 | |||
| 40 | 36 | while ($other->valid() && $iterator->valid()) { |
|
| 41 | 30 | $iterator->next(); |
|
| 42 | 30 | $other->next(); |
|
| 43 | } |
||
| 44 | |||
| 45 | 36 | if ($other->valid() !== $iterator->valid()) { |
|
| 46 | 12 | return yield false; |
|
| 47 | } |
||
| 48 | |||
| 49 | 24 | $containsCallback = static fn (int $index, mixed $current): bool => (new Contains())()([$current])($otherAggregate)->current(); |
|
| 50 | |||
| 51 | 24 | yield from (new Every())()($containsCallback)($iteratorAggregate); |
|
| 52 | 36 | }; |
|
| 55 |