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