Completed
Push — master ( 742ff7...9d59a2 )
by Nikola
09:00
created

FileConfigLoader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A load() 0 8 2
A loadFromPath() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Phoundation\Config;
6
7
use function Phoundation\mergeConfig;
8
9
final class FileConfigLoader implements ConfigLoader
10
{
11
    /** @var array */
12
    private $paths;
13
14
    /** @var array */
15
    private $config = [];
16
17
    public function __construct(array $paths)
18
    {
19
        $this->paths = $paths;
20
    }
21
22
    public function load(): array
23
    {
24
        foreach ($this->paths as $path) {
25
            $this->loadFromPath($path);
26
        }
27
28
        return $this->config;
29
    }
30
31
    private function loadFromPath(string $path): void
32
    {
33
        $config = require $path;
34
        $this->config = mergeConfig($this->config, $config);
35
    }
36
}
37