Total Complexity | 10 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class Params extends Config |
||
9 | { |
||
10 | protected function calcValues(array $sources): array |
||
13 | } |
||
14 | |||
15 | protected function pushEnvVars(array $vars): array |
||
16 | { |
||
17 | if (empty($vars)) { |
||
18 | return []; |
||
19 | } |
||
20 | |||
21 | $env = $this->builder->getConfig('envs')->getValues(); |
||
22 | |||
23 | foreach ($vars as $key => &$value) { |
||
24 | if (is_array($value)) { |
||
25 | foreach (array_keys($value) as $subkey) { |
||
26 | $envKey = $this->getEnvKey($key . '_' . $subkey); |
||
27 | if (isset($env[$envKey])) { |
||
28 | $value[$subkey] = $env[$envKey]; |
||
29 | } |
||
30 | } |
||
31 | } else { |
||
32 | $envKey = $this->getEnvKey($key); |
||
33 | if (isset($env[$envKey])) { |
||
34 | $vars[$key] = $env[$envKey]; |
||
35 | } |
||
36 | } |
||
37 | } |
||
38 | |||
39 | return $vars; |
||
40 | } |
||
41 | |||
42 | private function getEnvKey(string $key): string |
||
43 | { |
||
44 | return strtoupper(strtr($key, '.-', '__')); |
||
45 | } |
||
46 | |||
47 | public function paramsRequired(): bool |
||
50 | } |
||
51 | } |
||
52 |