Root   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A applyTo() 0 8 2
1
<?php
2
3
/**
4
 * This file is part of cloak.
5
 *
6
 * (c) Noritaka Horio <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace cloak\configuration;
13
14
use Zend\Config\Config;
15
use cloak\configuration\section\Target;
16
use cloak\configuration\section\Report;
17
use cloak\configuration\section\Reporter;
18
19
20
/**
21
 * Class Root
22
 * @package cloak\configuration
23
 */
24
final class Root implements Section
25
{
26
27
    /**
28
     * @var Section[]
29
     */
30
    private $configurations = [];
31
32
33
    /**
34
     * @param array $values
35
     */
36
    public function __construct(array $values = [])
37
    {
38
        $config = new Config($values);
39
        $emptyConfig = new Config([]);
40
41
        $target = $config->get('target', $emptyConfig)->toArray();
42
        $this->configurations[] = new Target($target);
43
44
        $target = $config->get('report', $emptyConfig)->toArray();
45
        $this->configurations[] = new Report($target);
46
47
        $reporter = $config->get('reporter', $emptyConfig)->toArray();
48
        $this->configurations[] = new Reporter($reporter);
49
    }
50
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function applyTo(ConfigurationBuilder $builder)
56
    {
57
        foreach ($this->configurations as $configuration) {
58
            $configuration->applyTo($builder);
59
        }
60
61
        return $builder;
62
    }
63
64
}
65