| Total Complexity | 10 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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(array $data): array |
||
| 16 | { |
||
| 17 | if (empty($data)) { |
||
| 18 | return []; |
||
| 19 | } |
||
| 20 | |||
| 21 | $env = $this->builder->getConfig('envs')->getValues(); |
||
| 22 | |||
| 23 | return self::pushValues($data, $env); |
||
| 24 | } |
||
| 25 | |||
| 26 | public static function pushValues(array $data, array $values, string $prefix = null) |
||
| 27 | { |
||
| 28 | foreach ($data as $key => &$value) { |
||
| 29 | $subkey = $prefix===null ? $key : "${prefix}_$key"; |
||
| 30 | |||
| 31 | $envkey = self::getEnvKey($subkey); |
||
| 32 | if (isset($values[$envkey])) { |
||
| 33 | $value = $values[$envkey]; |
||
| 34 | } elseif (is_array($value)) { |
||
| 35 | $value = self::pushValues($value, $values, $subkey); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | return $data; |
||
| 40 | } |
||
| 41 | |||
| 42 | private static function getEnvKey(string $key): string |
||
| 45 | } |
||
| 46 | |||
| 47 | protected function paramsRequired(): bool |
||
| 50 | } |
||
| 51 | } |
||
| 52 |