Conditions | 3 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
39 | 117 | public function normalize(string $text, array $context = []): string |
|
40 | { |
||
41 | 117 | $normalized = $this->innerNormalizer->normalize($text, $context); |
|
42 | |||
43 | // If it's not unique, add an incremental number to the end until we get a unique version |
||
44 | 117 | if (\array_key_exists($normalized, $this->alreadyUsed)) { |
|
45 | 24 | $suffix = 0; |
|
46 | do { |
||
47 | 24 | ++$suffix; |
|
48 | 24 | } while (\array_key_exists("$normalized-$suffix", $this->alreadyUsed)); |
|
49 | |||
50 | 24 | $normalized = "$normalized-$suffix"; |
|
51 | } |
||
52 | |||
53 | 117 | $this->alreadyUsed[$normalized] = true; |
|
54 | |||
55 | 117 | return $normalized; |
|
56 | } |
||
58 |