| Total Complexity | 10 |
| Total Lines | 45 |
| 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 ($vars === []) { |
||
| 18 | return []; |
||
| 19 | } |
||
| 20 | |||
| 21 | $env = array_merge( |
||
| 22 | $this->builder->getConfig('envs')->getValues(), |
||
| 23 | $this->builder->getConfig('dotenv')->getValues() |
||
| 24 | ); |
||
| 25 | |||
| 26 | foreach ($vars as $key => &$value) { |
||
| 27 | if (is_array($value)) { |
||
| 28 | foreach (array_keys($value) as $subkey) { |
||
| 29 | $envKey = $this->getEnvKey($key . '_' . $subkey); |
||
| 30 | if (isset($env[$envKey])) { |
||
| 31 | $value[$subkey] = $env[$envKey]; |
||
| 32 | } |
||
| 33 | } |
||
| 34 | } else { |
||
| 35 | $envKey = $this->getEnvKey($key); |
||
| 36 | if (isset($env[$envKey])) { |
||
| 37 | $vars[$key] = $env[$envKey]; |
||
| 38 | } |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | return $vars; |
||
| 43 | } |
||
| 44 | |||
| 45 | private function getEnvKey(string $key): string |
||
| 46 | { |
||
| 47 | return strtoupper(strtr($key, '.-', '__')); |
||
| 48 | } |
||
| 49 | |||
| 50 | public function paramsRequires(): bool |
||
| 53 | } |
||
| 54 | } |
||
| 55 |