Passed
Push — master ( 14a42b...4e4f6b )
by Andrii
02:16
created

Params   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
eloc 9
dl 0
loc 20
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A calcValues() 0 3 1
A pushEnvVars() 0 13 4
1
<?php
2
/**
3
 * Composer plugin for config assembling
4
 *
5
 * @link      https://github.com/hiqdev/composer-config-plugin
6
 * @package   composer-config-plugin
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\composer\config\configs;
12
13
/**
14
 * Params class represents output configuration file with params definitions.
15
 *
16
 * @author Andrii Vasyliev <[email protected]>
17
 */
18
class Params extends Config
19
{
20
    protected function calcValues(array $sources)
21
    {
22
        return $this->pushEnvVars(parent::calcValues($sources));
23
    }
24
25
    protected function pushEnvVars($vars)
26
    {
27
        $env = $this->builder->getConfig('dotenv')->getValues();
28
        if (!empty($vars)) {
29
            foreach (array_keys($vars) as $key) {
30
                $envKey = strtoupper(strtr($key, '.', '_'));
31
                if (isset($env[$envKey])) {
32
                    $vars[$key] = $env[$envKey];
33
                }
34
            }
35
        }
36
37
        return $vars;
38
    }
39
}
40