Completed
Pull Request — master (#8)
by Woody
01:56
created

ConfigCollection::set()   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 2
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;
1 ignored issue
show
Documentation Bug introduced by
It seems like $configs of type array<integer,object<Nor...onfig\ConfigInterface>> is incompatible with the declared type object<Northwoods\Config\ConfigInterface> of property $configs.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
15 2
    }
16
17 2
    public function get($dotPath, $default = null)
18
    {
19 2
        foreach ($this->configs as $config) {
1 ignored issue
show
Bug introduced by
The expression $this->configs of type object<Northwoods\Config\ConfigInterface> is not traversable.
Loading history...
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