| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | protected function translate(string $text, string $pattern = '/[^{\}]+(?=})/'): string |
||
| 25 | { |
||
| 26 | preg_match_all($pattern, $text, $matches); |
||
| 27 | |||
| 28 | if (0 === \count($matches[0])) { |
||
| 29 | return $text; |
||
| 30 | } |
||
| 31 | |||
| 32 | $replace_vars = []; |
||
| 33 | |||
| 34 | foreach ($matches[0] as $match) { |
||
| 35 | $var = Str::slug($match, '_'); |
||
| 36 | $replace_vars["{{$match}}"] = $this->cache->get("{$this->prefix}_{$var}", "{{$var}}"); |
||
| 37 | } |
||
| 38 | |||
| 39 | return strtr($text, $replace_vars); |
||
| 40 | } |
||
| 42 |