ConfigurationSet::apply()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 8
cts 8
cp 1
rs 9.6666
cc 3
eloc 5
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Equip\Configuration;
4
5
use Auryn\Injector;
6
use Equip\Exception\ConfigurationException;
7
use Equip\Structure\Set;
8
9
class ConfigurationSet extends Set implements ConfigurationInterface
10
{
11
    /**
12
     * @inheritDoc
13
     */
14 2
    public function apply(Injector $injector)
15
    {
16 2
        foreach ($this as $configuration) {
17 2
            if (!is_object($configuration)) {
18 1
                $configuration = $injector->make($configuration);
19 1
            }
20 2
            $configuration->apply($injector);
21 2
        }
22 2
    }
23
24
    /**
25
     * @inheritDoc
26
     *
27
     * @throws ConfigurationException
28
     *  If $classes does not implement the correct interface.
29
     */
30 3
    protected function assertValid(array $classes)
31
    {
32 3
        parent::assertValid($classes);
33
34 3
        foreach ($classes as $config) {
35 3
            if (!is_subclass_of($config, ConfigurationInterface::class)) {
36 1
                throw ConfigurationException::invalidClass($config);
37
            }
38 3
        }
39 3
    }
40
}
41