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