| Conditions | 1 |
| Paths | 1 |
| Total Lines | 9 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function translate(string $key, array $variables = []): string |
||
| 14 | { |
||
| 15 | $translatedText = $this->translationRepository->getTranslation($key); |
||
| 16 | |||
| 17 | $replacements = collect($variables)->mapWithKeys(fn ($value, $placeholder) => [ |
||
|
|
|||
| 18 | '{' . trim($placeholder, '{}') . '}' => $value, |
||
| 19 | ])->toArray(); |
||
| 20 | |||
| 21 | return strtr($translatedText, $replacements); |
||
| 22 | } |
||
| 24 |