Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
24 | final class ChangesCountNameGenerator implements NameGeneratorInterface |
||
25 | { |
||
26 | public function generate(Atomizer $atomizer): string |
||
27 | { |
||
28 | $collector = new Collector(); |
||
29 | $map = []; |
||
30 | foreach ($collector->collect($atomizer) as $pair) { |
||
31 | $key = $this->changeToString($pair[0]); |
||
32 | $map[$key] ??= 0; |
||
33 | $map[$key]++; |
||
34 | } |
||
35 | |||
36 | $result = []; |
||
37 | foreach ($map as $key => $cnt) { |
||
38 | $result[] = "{$key}{$cnt}"; |
||
39 | } |
||
40 | |||
41 | return \implode('_', $result); |
||
42 | } |
||
43 | |||
44 | private function changeToString(ChangeType $change): string |
||
60 | }; |
||
61 | } |
||
63 |