| Conditions | 6 |
| Paths | 17 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | function interpolate($string, array $values, $prefix = '{', $postfix = '}') |
||
| 23 | { |
||
| 24 | $replaces = []; |
||
| 25 | foreach ($values as $key => $value) { |
||
| 26 | $value = (is_array($value) || $value instanceof \Closure) ? '' : $value; |
||
| 27 | |||
| 28 | try { |
||
| 29 | //Object as string |
||
| 30 | $value = is_object($value) ? (string)$value : $value; |
||
| 31 | } catch (\Exception $e) { |
||
| 32 | $value = ''; |
||
| 33 | } |
||
| 34 | |||
| 35 | $replaces[$prefix . $key . $postfix] = $value; |
||
| 36 | } |
||
| 37 | |||
| 38 | return strtr($string, $replaces); |
||
| 39 | } |
||
| 40 |