Passed
Push — master ( 03c598...1d0b53 )
by Krisztián
01:58
created

ConfigAggregator::getMergedConfig()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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