Total Complexity | 9 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
20 | class Interpolator |
||
21 | { |
||
22 | public $data; |
||
23 | |||
24 | public function interpolate(&$data) |
||
28 | } |
||
29 | |||
30 | private function interpolateArray(&$data) |
||
31 | { |
||
32 | if (is_array($data)) { |
||
33 | foreach ($data as &$item) { |
||
34 | $this->interpolateArray($item); |
||
35 | } |
||
36 | } elseif (is_string($data)) { |
||
37 | $data = preg_replace_callback('/\\$(\\w+)\\[\'(.+?)\'\\]/', function ($matches) { |
||
38 | return $this->get($matches[1], $matches[2]); |
||
39 | }, $data); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | public function get($scope, $name) |
||
44 | { |
||
45 | if ($scope === 'params') { |
||
46 | return $this->data['params'][$name]; |
||
47 | } elseif ($scope === '_ENV') { |
||
48 | return $_ENV[$name]; |
||
49 | } else { |
||
50 | return "\$${scope}['$name']"; |
||
51 | } |
||
52 | } |
||
53 | |||
54 | public function getConfig($name) |
||
59 | } |
||
60 | } |
||
61 |