| Conditions | 4 |
| Paths | 1 |
| Total Lines | 21 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 21 | 123 | public function __invoke(): Closure |
|
| 22 | { |
||
| 23 | 123 | return |
|
| 24 | /** |
||
| 25 | * @return Closure(iterable<TKey, T>): Generator<mixed, mixed> |
||
| 26 | */ |
||
| 27 | 123 | static fn (int $depth): Closure => |
|
| 28 | /** |
||
| 29 | * @param iterable<TKey, T> $iterable |
||
| 30 | */ |
||
| 31 | 123 | static function (iterable $iterable) use ($depth): Generator { |
|
| 32 | 121 | foreach ($iterable as $key => $value) { |
|
| 33 | 117 | if (!is_iterable($value)) { |
|
| 34 | 8 | yield $key => $value; |
|
| 35 | |||
| 36 | 8 | continue; |
|
| 37 | } |
||
| 38 | |||
| 39 | 117 | yield from (1 !== $depth) |
|
| 40 | 4 | ? (new Flatten())()($depth - 1)($value) |
|
| 41 | 117 | : $value; |
|
| 42 | } |
||
| 46 |