Environment   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createKey() 0 3 1
A __construct() 0 9 3
1
<?php
2
3
/**
4
 * This file is part of slick/configuration
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Configuration\Driver;
11
12
use Slick\Configuration\ConfigurationInterface;
13
14
/**
15
 * Environment
16
 *
17
 * @package Slick\Configuration\Driver
18
*/
19
class Environment implements ConfigurationInterface
20
{
21
22
    use CommonDriverMethods;
23
24
    public function __construct()
25
    {
26
        $envVars = getenv();
27
        if (!is_array($envVars)) {
0 ignored issues
show
introduced by
The condition is_array($envVars) is always true.
Loading history...
28
            return;
29
        }
30
31
        foreach ($envVars as $key => $value) {
32
            $this->set($this->createKey($key), $value);
33
        }
34
    }
35
36
    private function createKey(string $envName): string
37
    {
38
        return trim(strtolower(str_replace('_', '.', $envName)), '.');
39
    }
40
}
41