| Conditions | 5 |
| Paths | 3 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 1 | private function interpolate($message, array $context = []) |
|
| 27 | { |
||
| 28 | // build a replacement array with braces around the context keys |
||
| 29 | 1 | $replace = []; |
|
| 30 | 1 | foreach ($context as $key => $val) { |
|
| 31 | // check that the value can be casted to string |
||
| 32 | 1 | if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { |
|
| 33 | 1 | $replace['{'.$key.'}'] = $val; |
|
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | // interpolate replacement values into the message and return |
||
| 38 | 1 | return strtr($message, $replace); |
|
| 39 | } |
||
| 41 |