Completed
Pull Request — master (#1)
by Woody
27:07 queued 01:07
created

ConfigurationSet::apply()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6667
cc 3
eloc 5
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Equip\Configuration;
4
5
use Auryn\Injector;
6
use Destrukt\Set;
7
use Equip\Exception\ConfigurationException;
8
9
class ConfigurationSet extends Set implements ConfigurationInterface
10
{
11
    /**
12
     * @inheritDoc
13
     *
14
     * @throws ConfigurationException If any class is not of the expected type
15
     */
16 4
    public function validate(array $classes)
17
    {
18 4
        parent::validate($classes);
19
20 4
        foreach ($classes as $class) {
21 4
            if (!is_subclass_of($class, ConfigurationInterface::class)) {
22 4
                throw ConfigurationException::invalidClass($class);
23
            }
24
        }
25 3
    }
26
27
    /**
28
     * @inheritDoc
29
     */
30 3
    public function apply(Injector $injector)
31
    {
32 3
        foreach ($this as $configuration) {
33 3
            if (!is_object($configuration)) {
34 2
                $configuration = $injector->make($configuration);
35
            }
36 3
            $configuration->apply($injector);
37
        }
38 3
    }
39
}
40