| Conditions | 4 | 
| Paths | 6 | 
| Total Lines | 21 | 
| Code Lines | 12 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 14 | 
| CRAP Score | 4 | 
| Changes | 0 | ||
| 1 | <?php | ||
| 29 | 11 | private function chunk(array $tokenList, $separator = Token::DASH_SEPARATOR) | |
| 30 |     { | ||
| 31 | 11 | $chunkList = []; | |
| 32 | 11 | $accumulator = []; | |
| 33 | |||
| 34 | // Split token stream by dash separators | ||
| 35 | 11 |         for ($i = 0; $i < count($tokenList); $i++) { | |
| 1 ignored issue–
                            show | |||
| 36 | 11 |             if ($separator !== $tokenList[$i]->getType()) { | |
| 37 | 11 | $accumulator[] = $tokenList[$i]; | |
| 38 | 11 |             } else { | |
| 39 | 10 | $chunkList[] = $accumulator; | |
| 40 | 10 | $accumulator = []; | |
| 41 | } | ||
| 42 | 11 | } | |
| 43 | |||
| 44 | 11 |         if (count($accumulator)) { | |
| 45 | 11 | $chunkList[] = $accumulator; | |
| 46 | 11 | } | |
| 47 | |||
| 48 | 11 | return $chunkList; | |
| 49 | } | ||
| 50 | } | 
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: