Conditions | 4 |
Paths | 6 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | 6 | public function modifyAll(TokenCollection $tokenCollection): TokenCollection |
|
21 | 4 | { |
|
22 | $oldKeys = []; |
||
23 | foreach ($tokenCollection->getTokens() as $token) { |
||
24 | 6 | $oldKeys[] = $token->getTranslationKey(); |
|
25 | 2 | } |
|
26 | |||
27 | if (empty($oldKeys)) { |
||
28 | 4 | return $tokenCollection; |
|
29 | 4 | } |
|
30 | 4 | ||
31 | $oldToNewKeys = $this->translator->translate($oldKeys); |
||
32 | 4 | foreach ($tokenCollection->getTokens() as $token) { |
|
33 | $token->changeTranslationKey($oldToNewKeys[$token->getTranslationKey()] ?? $token->getTranslationKey()); |
||
34 | } |
||
35 | return $tokenCollection; |
||
36 | } |
||
38 |