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