@@ -9,59 +9,59 @@ |
||
9 | 9 | |
10 | 10 | class MergeSuffix extends AbstractPass |
11 | 11 | { |
12 | - /** |
|
13 | - * {@inheritdoc} |
|
14 | - */ |
|
15 | - protected function processStrings(array $strings) |
|
16 | - { |
|
17 | - if (!$this->isEligible($strings)) |
|
18 | - { |
|
19 | - return $strings; |
|
20 | - } |
|
12 | + /** |
|
13 | + * {@inheritdoc} |
|
14 | + */ |
|
15 | + protected function processStrings(array $strings) |
|
16 | + { |
|
17 | + if (!$this->isEligible($strings)) |
|
18 | + { |
|
19 | + return $strings; |
|
20 | + } |
|
21 | 21 | |
22 | - $newString = []; |
|
23 | - while ($this->hasMatchingSuffix($strings)) |
|
24 | - { |
|
25 | - array_unshift($newString, end($strings[0])); |
|
26 | - $i = count($strings); |
|
27 | - while (--$i >= 0) |
|
28 | - { |
|
29 | - array_pop($strings[$i]); |
|
30 | - } |
|
31 | - } |
|
32 | - array_unshift($newString, $strings); |
|
22 | + $newString = []; |
|
23 | + while ($this->hasMatchingSuffix($strings)) |
|
24 | + { |
|
25 | + array_unshift($newString, end($strings[0])); |
|
26 | + $i = count($strings); |
|
27 | + while (--$i >= 0) |
|
28 | + { |
|
29 | + array_pop($strings[$i]); |
|
30 | + } |
|
31 | + } |
|
32 | + array_unshift($newString, $strings); |
|
33 | 33 | |
34 | - return [$newString]; |
|
35 | - } |
|
34 | + return [$newString]; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Test whether all given strings have the same last element |
|
39 | - * |
|
40 | - * @param array[] $strings |
|
41 | - * @return bool |
|
42 | - */ |
|
43 | - protected function hasMatchingSuffix(array $strings) |
|
44 | - { |
|
45 | - $suffix = end($strings[1]); |
|
46 | - foreach ($strings as $string) |
|
47 | - { |
|
48 | - if (end($string) !== $suffix) |
|
49 | - { |
|
50 | - return false; |
|
51 | - } |
|
52 | - } |
|
37 | + /** |
|
38 | + * Test whether all given strings have the same last element |
|
39 | + * |
|
40 | + * @param array[] $strings |
|
41 | + * @return bool |
|
42 | + */ |
|
43 | + protected function hasMatchingSuffix(array $strings) |
|
44 | + { |
|
45 | + $suffix = end($strings[1]); |
|
46 | + foreach ($strings as $string) |
|
47 | + { |
|
48 | + if (end($string) !== $suffix) |
|
49 | + { |
|
50 | + return false; |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - return ($suffix !== false); |
|
55 | - } |
|
54 | + return ($suffix !== false); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Test whether this pass can be run on given list of strings |
|
59 | - * |
|
60 | - * @param array[] $strings |
|
61 | - * @return bool |
|
62 | - */ |
|
63 | - protected function isEligible(array $strings) |
|
64 | - { |
|
65 | - return (count($strings) > 1 && $this->hasMatchingSuffix($strings)); |
|
66 | - } |
|
57 | + /** |
|
58 | + * Test whether this pass can be run on given list of strings |
|
59 | + * |
|
60 | + * @param array[] $strings |
|
61 | + * @return bool |
|
62 | + */ |
|
63 | + protected function isEligible(array $strings) |
|
64 | + { |
|
65 | + return (count($strings) > 1 && $this->hasMatchingSuffix($strings)); |
|
66 | + } |
|
67 | 67 | } |
68 | 68 | \ No newline at end of file |