Report::applyCoverageBounds()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 15
rs 9.4285
cc 1
eloc 9
nc 1
nop 1
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\value\Path;
18
use Zend\Config\Config;
19
20
21
/**
22
 * Class Report
23
 * @package cloak\configuration\section
24
 */
25
final class Report extends AbstractSection implements Section
26
{
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function applyTo(ConfigurationBuilder $builder)
32
    {
33
        $this->applyReportDirectory($builder)
34
            ->applyCoverageBounds($builder);
35
36
        return $builder;
37
    }
38
39
    /**
40
     * @param ConfigurationBuilder $builder
41
     * @return $this
42
     */
43
    private function applyReportDirectory(ConfigurationBuilder $builder)
44
    {
45
        $reportDirectory = $this->getValue('reportDirectory', getcwd());
46
47
        $path = Path::fromString($reportDirectory);
48
        $builder->reportDirectory((string) $path);
49
50
        return $this;
51
    }
52
53
    /**
54
     * @param ConfigurationBuilder $builder
55
     * @return $this
56
     */
57
    private function applyCoverageBounds(ConfigurationBuilder $builder)
58
    {
59
        $default = new Config([
60
            'critical' => 35.0,
61
            'satisfactory' => 70.0
62
        ]);
63
64
        $coverageBounds = $this->getValue('coverageBounds', $default);
65
        $critical = $coverageBounds->get('critical');
66
        $satisfactory = $coverageBounds->get('satisfactory');
67
68
        $builder->coverageBounds($critical, $satisfactory);
69
70
        return $this;
71
    }
72
73
}
74