| Conditions | 4 |
| Paths | 6 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public static function slice($characters, $size) |
||
| 16 | { |
||
| 17 | $start = Codepoint::MIN; |
||
| 18 | $tally = 0; |
||
| 19 | $chunk = []; |
||
| 20 | |||
| 21 | foreach ($characters as $character) { |
||
| 22 | array_push($chunk, $character); |
||
| 23 | $codepoint = $character->getCodepoint(); |
||
| 24 | $current = $codepoint->getValue(); |
||
| 25 | |||
| 26 | if ((++$tally % $size) === 0) { |
||
| 27 | yield (new Range($start, $current)) => $chunk; |
||
| 28 | $chunk = []; |
||
| 29 | $start = ++$current; |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | if (count($chunk) > 0) { |
||
| 34 | yield (new Range($start, Codepoint::MAX)) => $chunk; |
||
| 35 | } |
||
| 36 | } |
||
| 37 | } |