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