CoverageAnalyzer::stop()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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;
13
14
15
/**
16
 * Class CoverageAnalyzer
17
 * @package cloak
18
 */
19
class CoverageAnalyzer implements AnalyzeLifeCycleNotifierAware, ReportableAnalyzer
20
{
21
22
    use ProvidesLifeCycleNotifier;
23
24
    /**
25
     * @var AnalyzerConfiguration
26
     */
27
    protected $config;
28
29
    /**
30
     * @var AnalyzedCoverageResult
31
     */
32
    protected $analyzeResult;
33
34
35
    /**
36
     * @param AnalyzerConfiguration $config
37
     */
38
    public function __construct(AnalyzerConfiguration $config)
39
    {
40
        $this->init($config);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function start()
47
    {
48
        $this->getLifeCycleNotifier()->notifyStart();
49
        $this->getDriver()->start();
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function stop()
56
    {
57
        $this->getDriver()->stop();
58
        $this->getLifeCycleNotifier()->notifyStop( $this->getResult() );
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function isStarted()
65
    {
66
        return $this->getDriver()->isStarted();
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function getResult()
73
    {
74
        $analyzeResult = $this->getDriver()->getAnalyzeResult();
75
        $analyzeResult = $this->config->applyTo($analyzeResult);
76
        return AnalyzedCoverageResult::fromAnalyzeResult($analyzeResult);
77
    }
78
79
    /**
80
     * @return \cloak\analyzer\AnalyzeDriver
81
     */
82
    protected function getDriver()
83
    {
84
        $driver = $this->config->getDriver();
85
        return $driver;
86
    }
87
88
    /**
89
     * @param AnalyzerConfiguration $config
90
     */
91
    protected function init(AnalyzerConfiguration $config)
92
    {
93
        $this->config = $config;
94
        $reporter = $config->getReporter();
95
        $this->setLifeCycleNotifier( new AnalyzeLifeCycleNotifier($reporter) );
96
        $this->getLifeCycleNotifier()->notifyInitialize($this->config);
97
    }
98
99
}
100