LineResult::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\result;
13
14
/**
15
 * Class LineResult
16
 * @package cloak\analyzer\result
17
 */
18
class LineResult
19
{
20
21
    const EXECUTED = 1;
22
    const UNUSED = -1;
23
    const DEAD = -2;
24
25
//    private $file = null;
26
    private $lineNumber = null;
27
    private $analyzeResult = null;
28
29
    public function __construct($lineNumber = 0, $analyzeResult = self::EXECUTED)
30
    {
31
        $this->lineNumber = $lineNumber;
32
        $this->analyzeResult = $analyzeResult;
33
    }
34
35
//    public function isFileAssociated()
36
  //  {
37
    //    return is_null($this->file) === false;
38
//    }
39
40
//    public function link(FileResult $file)
41
  //  {
42
    //    $this->file = $file;
43
//    }
44
45
//    public function unlink()
46
  //  {
47
    //    $this->file = null;
48
//    }
49
50
//    public function getFile()
51
  //  {
52
    //    return $this->file;
53
//    }
54
55
    public function getLineNumber()
56
    {
57
        return $this->lineNumber;
58
    }
59
60
    public function getAnalyzeResult()
61
    {
62
        return $this->analyzeResult;
63
    }
64
65
    public function isDead()
66
    {
67
        return $this->analyzeResult === self::DEAD;
68
    }
69
70
    public function isUnused()
71
    {
72
        return $this->analyzeResult === self::UNUSED;
73
    }
74
75
    public function isExecuted()
76
    {
77
        return $this->analyzeResult === self::EXECUTED;
78
    }
79
80
    public function isValid()
81
    {
82
        $analyzeResult = ($this->isDead() || $this->isExecuted() || $this->isUnused());
83
        return $this->getLineNumber() > 0 && $analyzeResult === true;
84
    }
85
86
    public function equals(LineResult $line)
87
    {
88
        return ($line->getLineNumber() === $this->getLineNumber() && $line->getAnalyzeResult() === $this->getAnalyzeResult());
89
    }
90
91
}
92