Reporter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A applyTo() 0 4 1
A loadReporters() 0 13 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\section;
13
14
use cloak\configuration\ConfigurationBuilder;
15
use cloak\configuration\AbstractSection;
16
use cloak\configuration\Section;
17
use cloak\reporter\CompositeReporter;
18
use cloak\reporter\ReporterFactory;
19
20
21
/**
22
 * Class Reporter
23
 * @package cloak\configuration
24
 */
25
final class Reporter extends AbstractSection implements Section
26
{
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function applyTo(ConfigurationBuilder $builder)
32
    {
33
        return $builder->reporter($this->loadReporters());
34
    }
35
36
    /**
37
     * @return CompositeReporter
38
     */
39
    private function loadReporters()
40
    {
41
        $reporters = [];
42
43
        foreach ($this->getValues() as $reporterName => $arguments) {
44
            $factory = ReporterFactory::fromName($reporterName);
45
            $reporter = $factory->createWithArguments( $arguments->toArray() );
46
47
            $reporters[] = $reporter;
48
        }
49
50
        return new CompositeReporter($reporters);
51
    }
52
53
}
54