Analyzer::getAnalyzeResult()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
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\analyzer;
13
14
15
/**
16
 * Class Analyzer
17
 * @package cloak\analyzer
18
 */
19
final class Analyzer implements AnalyzeDriver
20
{
21
22
    /**
23
     * @var AnalyzeAdapter
24
     */
25
    private $adapter;
26
27
28
    /**
29
     * @var boolean
30
     */
31
    private $started = false;
32
33
    /**
34
     * @var array
35
     */
36
    private $analyzeResult = [];
37
38
39
    /**
40
     * @param AnalyzeAdapter $adapter
41
     */
42
    public function __construct(AnalyzeAdapter $adapter)
43
    {
44
        $this->adapter = $adapter;
45
    }
46
47
48
    public function start()
49
    {
50
        $this->adapter->start();
51
        $this->started = true;
52
    }
53
54
    public function stop()
55
    {
56
        $result = $this->adapter->stop();
57
        $this->analyzeResult = $result;
58
        $this->started = false;
59
    }
60
61
    /**
62
     * @return boolean
63
     */
64
    public function isStarted()
65
    {
66
        return $this->started;
67
    }
68
69
    /**
70
     * @return AnalyzedResult
71
     */
72
    public function getAnalyzeResult()
73
    {
74
        return AnalyzedResult::fromArray($this->analyzeResult);
75
    }
76
77
}
78