| Total Complexity | 4 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 14 | class GroupSingleCharacters extends AbstractPass |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * {@inheritdoc} |
||
| 18 | 4 | */ |
|
| 19 | protected function runPass(array $strings): array |
||
| 20 | 4 | { |
|
| 21 | 4 | $singles = $this->getSingleCharStrings($strings); |
|
| 22 | 4 | $cnt = count($singles); |
|
| 23 | if ($cnt > 1 && $cnt < count($strings)) |
||
| 24 | { |
||
| 25 | 1 | // Remove the singles from the input, then prepend them as a new string |
|
| 26 | 1 | $strings = array_diff_key($strings, $singles); |
|
| 27 | array_unshift($strings, [array_values($singles)]); |
||
| 28 | } |
||
| 29 | 4 | ||
| 30 | return $strings; |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Return an array of every single-char string in given list of strings |
||
| 35 | * |
||
| 36 | * @param array[] $strings |
||
| 37 | * @return array[] |
||
| 38 | 4 | */ |
|
| 39 | protected function getSingleCharStrings(array $strings): array |
||
| 42 | } |
||
| 43 | } |