ConfigAggregator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpCache\ServiceManager;
4
5
/**
6
 * This class enables to use multiple configuration files or owerwrite core settings.
7
 * Use this class to merge multiple config arrays before creating a ServiceManager instance.
8
 *
9
 * @author kdudas
10
 */
11
class ConfigAggregator
12
{
13
    private $configs;
14
15
    private $mergedConfig;
16
17
    public function __construct()
18
    {
19
        $this->configs = [];
20
        $this->mergedConfig = [];
21
    }
22
23
    public function addConfig(array $config): void
24
    {
25
        $this->configs[] = $config;
26
    }
27
28
    public function getMergedConfig(): array
29
    {
30
        foreach ($this->configs as $config) {
31
            $this->mergedConfig = array_merge_recursive($this->mergedConfig, $config);
32
        }
33
34
        return $this->mergedConfig;
35
    }
36
}
37