| Conditions | 7 |
| Paths | 4 |
| Total Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 7.9295 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | 13 | private function resolveValue(ContainerInterface $container, $value) |
|
| 30 | { |
||
| 31 | 13 | if (is_array($value)) { |
|
| 32 | foreach ($value as $key => $val) { |
||
| 33 | $value[$key] = $this->resolveValue($container, $val); |
||
| 34 | } |
||
| 35 | |||
| 36 | return $value; |
||
| 37 | } |
||
| 38 | |||
| 39 | 13 | if (!is_string($value)) { |
|
| 40 | 7 | return $value; |
|
| 41 | } |
||
| 42 | |||
| 43 | $escapedValue = preg_replace_callback('/%%|%([^%\s]++)%/', function ($match) use ($container, $value) { |
||
| 44 | // skip %% |
||
| 45 | 6 | if (!isset($match[1])) { |
|
| 46 | 6 | return '%%'; |
|
| 47 | } |
||
| 48 | |||
| 49 | 6 | $resolved = $container->getParameter($match[1]); |
|
| 50 | 6 | if (is_string($resolved) || is_numeric($resolved)) { |
|
| 51 | 6 | return (string) $resolved; |
|
| 52 | } |
||
| 53 | |||
| 54 | throw new \RuntimeException(sprintf('The container parameter "%s" must be a string or numeric, but it is of type %s.', $match[1], gettype($resolved))); |
||
| 55 | 12 | }, $value); |
|
| 56 | |||
| 57 | 12 | return str_replace('%%', '%', $escapedValue); |
|
| 58 | } |
||
| 59 | } |
||
| 60 |