| Conditions | 4 |
| Paths | 3 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | protected function translate($templateValue, array $data) |
||
| 21 | { |
||
| 22 | $translated = $templateValue; |
||
| 23 | |||
| 24 | if (preg_match('/{{(\w+)}}/', $templateValue, $regs)) { |
||
| 25 | $key = $regs[1]; |
||
| 26 | if (array_key_exists($key, $data) && !is_Array($data[$key])) { |
||
| 27 | $translated = preg_replace('/{{(\w+)}}/', $data[$key], $templateValue); |
||
| 28 | } else { |
||
| 29 | $this->logger->notice("Could not translate $templateValue", ['data-keys' => array_keys($data)]); |
||
| 30 | $translated = null; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | return $translated; |
||
| 35 | } |
||
| 36 | |||
| 50 |