Completed
Push — master ( bf1c9e...8c1053 )
by Woody
13s
created

ConfigCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
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