Total Complexity | 4 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class IteratorFactory |
||
9 | { |
||
10 | 5 | public static function directSequence($length): Iterator |
|
11 | { |
||
12 | 5 | $current = 0; |
|
13 | return new CallbackIterator(static function () use (& $current, $length) { |
||
14 | 5 | if ($current === $length) { |
|
15 | 3 | return (new IterateResult())->setAsRunOut(); |
|
16 | } |
||
17 | |||
18 | 5 | return (new IterateResult())->setValue($current++); |
|
19 | 5 | }); |
|
20 | } |
||
21 | |||
22 | 5 | public static function reverseSequence($length): Iterator |
|
31 | 5 | }); |
|
32 | } |
||
34 |