Conditions | 4 |
Paths | 6 |
Total Lines | 25 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
29 | 17 | private function chunk(array $tokenList, $separator = Token::DASH_SEPARATOR) |
|
30 | { |
||
31 | 17 | $tokenListCount = count($tokenList); |
|
32 | 17 | $chunkedList = []; |
|
33 | 17 | $accumulator = []; |
|
34 | |||
35 | 17 | for ($i = 0; $i < $tokenListCount; $i++) { |
|
36 | 17 | $token = $tokenList[$i]; |
|
37 | |||
38 | // Accumulate until we hit a dash |
||
39 | 17 | if ($separator !== $token->getType()) { |
|
40 | 17 | $accumulator[] = $token; |
|
41 | |||
1 ignored issue
–
show
|
|||
42 | 17 | } else { |
|
43 | 11 | $chunkedList[] = $accumulator; |
|
44 | 11 | $accumulator = []; |
|
45 | } |
||
46 | 17 | } |
|
47 | |||
48 | 17 | if (count($accumulator)) { |
|
49 | 17 | $chunkedList[] = $accumulator; |
|
50 | 17 | } |
|
51 | |||
52 | 17 | return $chunkedList; |
|
53 | } |
||
54 | } |