@@ -9,67 +9,67 @@ |
||
9 | 9 | |
10 | 10 | class CoalesceSingleCharacterPrefix extends AbstractPass |
11 | 11 | { |
12 | - /** |
|
13 | - * {@inheritdoc} |
|
14 | - */ |
|
15 | - protected function processStrings(array $strings) |
|
16 | - { |
|
17 | - $newStrings = []; |
|
18 | - foreach ($this->getEligibleKeys($strings) as $keys) |
|
19 | - { |
|
20 | - // Create a new string to hold the merged strings and replace the first element with |
|
21 | - // an empty character class |
|
22 | - $newString = $strings[$keys[0]]; |
|
23 | - $newString[0] = []; |
|
24 | - foreach ($keys as $key) |
|
25 | - { |
|
26 | - $newString[0][] = [$strings[$key][0]]; |
|
27 | - unset($strings[$key]); |
|
28 | - } |
|
29 | - $newStrings[] = $newString; |
|
30 | - } |
|
12 | + /** |
|
13 | + * {@inheritdoc} |
|
14 | + */ |
|
15 | + protected function processStrings(array $strings) |
|
16 | + { |
|
17 | + $newStrings = []; |
|
18 | + foreach ($this->getEligibleKeys($strings) as $keys) |
|
19 | + { |
|
20 | + // Create a new string to hold the merged strings and replace the first element with |
|
21 | + // an empty character class |
|
22 | + $newString = $strings[$keys[0]]; |
|
23 | + $newString[0] = []; |
|
24 | + foreach ($keys as $key) |
|
25 | + { |
|
26 | + $newString[0][] = [$strings[$key][0]]; |
|
27 | + unset($strings[$key]); |
|
28 | + } |
|
29 | + $newStrings[] = $newString; |
|
30 | + } |
|
31 | 31 | |
32 | - return array_merge($newStrings, $strings); |
|
33 | - } |
|
32 | + return array_merge($newStrings, $strings); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Filter the list of eligible keys and keep those that have at least two matches |
|
37 | - * |
|
38 | - * @param array[] $eligibleKeys List of lists of keys |
|
39 | - * @return array[] |
|
40 | - */ |
|
41 | - protected function filterEligibleKeys(array $eligibleKeys) |
|
42 | - { |
|
43 | - $filteredKeys = []; |
|
44 | - foreach ($eligibleKeys as $k => $keys) |
|
45 | - { |
|
46 | - if (count($keys) > 1) |
|
47 | - { |
|
48 | - $filteredKeys[] = $keys; |
|
49 | - } |
|
50 | - } |
|
35 | + /** |
|
36 | + * Filter the list of eligible keys and keep those that have at least two matches |
|
37 | + * |
|
38 | + * @param array[] $eligibleKeys List of lists of keys |
|
39 | + * @return array[] |
|
40 | + */ |
|
41 | + protected function filterEligibleKeys(array $eligibleKeys) |
|
42 | + { |
|
43 | + $filteredKeys = []; |
|
44 | + foreach ($eligibleKeys as $k => $keys) |
|
45 | + { |
|
46 | + if (count($keys) > 1) |
|
47 | + { |
|
48 | + $filteredKeys[] = $keys; |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - return $filteredKeys; |
|
53 | - } |
|
52 | + return $filteredKeys; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get a list of keys of strings eligible to be merged together, grouped by suffix |
|
57 | - * |
|
58 | - * @param array[] $strings |
|
59 | - * @return array[] |
|
60 | - */ |
|
61 | - protected function getEligibleKeys(array $strings) |
|
62 | - { |
|
63 | - $eligibleKeys = []; |
|
64 | - foreach ($strings as $k => $string) |
|
65 | - { |
|
66 | - if (!is_array($string[0]) && isset($string[1])) |
|
67 | - { |
|
68 | - $suffix = serialize(array_slice($string, 1)); |
|
69 | - $eligibleKeys[$suffix][] = $k; |
|
70 | - } |
|
71 | - } |
|
55 | + /** |
|
56 | + * Get a list of keys of strings eligible to be merged together, grouped by suffix |
|
57 | + * |
|
58 | + * @param array[] $strings |
|
59 | + * @return array[] |
|
60 | + */ |
|
61 | + protected function getEligibleKeys(array $strings) |
|
62 | + { |
|
63 | + $eligibleKeys = []; |
|
64 | + foreach ($strings as $k => $string) |
|
65 | + { |
|
66 | + if (!is_array($string[0]) && isset($string[1])) |
|
67 | + { |
|
68 | + $suffix = serialize(array_slice($string, 1)); |
|
69 | + $eligibleKeys[$suffix][] = $k; |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - return $this->filterEligibleKeys($eligibleKeys); |
|
74 | - } |
|
73 | + return $this->filterEligibleKeys($eligibleKeys); |
|
74 | + } |
|
75 | 75 | } |
76 | 76 | \ No newline at end of file |