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

ConfigAggregator   A

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
/*
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