Completed
Push — master ( ca1131...42ef77 )
by Woody
03:33
created

ConfigurationSet   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 33
rs 10
ccs 15
cts 15
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 9 3
A assertValid() 0 10 3
1
<?php
2
3
namespace Equip\Configuration;
4
5
use Auryn\Injector;
6
use Equip\Compatibility\StructureWithDataAlias;
7
use Equip\Exception\ConfigurationException;
8
use Equip\Structure\Set;
9
10
class ConfigurationSet extends Set implements ConfigurationInterface
11
{
12
    use StructureWithDataAlias;
13
14
    /**
15
     * @inheritDoc
16
     */
17 3
    public function apply(Injector $injector)
18
    {
19 3
        foreach ($this as $configuration) {
20 3
            if (!is_object($configuration)) {
21 2
                $configuration = $injector->make($configuration);
22 2
            }
23 3
            $configuration->apply($injector);
24 3
        }
25 3
    }
26
27
    /**
28
     * @inheritDoc
29
     *
30
     * @throws ConfigurationException If any class is not of the expected type
31
     */
32 9
    protected function assertValid(array $classes)
33
    {
34 9
        parent::assertValid($classes);
35
36 9
        foreach ($classes as $class) {
37 4
            if (!is_subclass_of($class, ConfigurationInterface::class)) {
38 1
                throw ConfigurationException::invalidClass($class);
39
            }
40 9
        }
41 9
    }
42
}
43