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

FileConfigLoader::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
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