ConfigAggregator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getMergedConfig() 0 7 2
A addConfig() 0 3 1
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