Conditions | 3 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
22 | 24 | public static function range(int $start, int $stop, $step = 1): \Generator |
|
23 | { |
||
24 | 24 | static::assertStep($step); |
|
25 | 20 | $i = $start; |
|
26 | 20 | $direction = $stop <=> $start; |
|
27 | 20 | $step = $direction * $step; |
|
28 | 20 | $halt = false; |
|
29 | 20 | while (!$halt) { |
|
30 | 20 | yield $i; |
|
31 | 20 | $i += $step; |
|
32 | 20 | if ((($i - $stop) <=> 0) === $direction) { |
|
33 | 20 | $halt = true; |
|
34 | } |
||
48 |