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

ConfigurationSet   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 31
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 10 3
A apply() 0 9 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