Completed
Push — master ( 8c1053...9934c8 )
by Woody
07:00
created

ConfigCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 29
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 11 3
A set() 0 4 1
1
<?php
2
3
namespace Northwoods\Config;
4
5
class ConfigCollection implements ConfigInterface
6
{
7
    /**
8
     * @var ConfigInterface[]
9
     */
10
    private $configs;
11
12 2
    public function __construct(ConfigInterface ...$configs)
13
    {
14 2
        $this->configs = $configs;
15 2
    }
16
17 2
    public function get($dotPath, $default = null)
18
    {
19 2
        foreach ($this->configs as $config) {
20 2
            $value = $config->get($dotPath, $default);
21 2
            if ($value !== $default) {
22 2
                return $value;
23
            }
24 2
        }
25
26 2
        return $default;
27
    }
28
29 2
    public function set($dotPath, $value)
30
    {
31 2
        $this->configs[0]->set($dotPath, $value);
32 2
    }
33
}
34