| Total Complexity | 6 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | final class InterruptableIteratorAggregate implements IteratorAggregate |
||
| 22 | { |
||
| 23 | public const BREAK = 'break'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var iterable<TKey, T> |
||
| 27 | */ |
||
| 28 | private iterable $iterable; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param iterable<TKey, T> $iterable |
||
| 32 | */ |
||
| 33 | 1 | public function __construct(iterable $iterable) |
|
| 34 | { |
||
| 35 | 1 | $this->iterable = $iterable; |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @return Generator<Generator<TKey, T>, array{0: TKey, 1: T}> |
||
| 40 | */ |
||
| 41 | 1 | public function getIterator(): Generator |
|
| 42 | { |
||
| 43 | 1 | $generator = $this->getGenerator(); |
|
| 44 | |||
| 45 | 1 | foreach ($generator as $key => $value) { |
|
| 46 | 1 | yield $generator => [$key, $value]; |
|
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return Generator<TKey, T> |
||
| 52 | */ |
||
| 53 | 1 | private function getGenerator(): Generator |
|
| 61 | } |
||
| 62 | } |
||
| 63 | } |
||
| 65 |