Completed
Pull Request — master (#335)
by Дмитрий
02:55
created

Block::isUnreachable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA\ControlFlow;
7
8
use PHPSA\ControlFlow\Node\AbstractNode;
9
10
class Block
11
{
12
    /**
13
     * @var bool
14
     */
15
    protected $unreachable = false;
16
17
    /**
18
     * @var AbstractNode[]
19
     */
20
    protected $children = [];
21
22
    /**
23
     * @var Block[]
24
     */
25
    public $parents = [];
26
27
    /**
28
     * @var Block|null
29
     */
30
    protected $exit;
31
32
    /**
33
     * @var int
34
     */
35
    protected $id;
36
37
    /**
38
     * @var string|null
39
     */
40
    public $label;
41
42
    /**
43
     * @param int  $id
44
     * @param bool $unreachable
45
     */
46 1
    public function __construct($id, $unreachable = false)
47
    {
48 1
        $this->id = $id;
49 1
        $this->unreachable = $unreachable;
50 1
    }
51
52
    /**
53
     * @param AbstractNode $node
54
     */
55 1
    public function addChildren(AbstractNode $node)
56
    {
57 1
        $this->children[] = $node;
58 1
    }
59
60
    /**
61
     * @param Block $exit
62
     */
63 1
    public function setExit(Block $exit)
64
    {
65 1
        $this->exit = $exit;
66 1
    }
67
68
    /**
69
     * @return AbstractNode[]
70
     */
71
    public function getChildren()
72
    {
73
        return $this->children;
74
    }
75
76
    /**
77
     * @return Block|null
78
     */
79
    public function getExit()
80
    {
81
        return $this->exit;
82
    }
83
84
    /**
85
     * @return int
86
     */
87
    public function getId()
88
    {
89
        return $this->id;
90
    }
91
92
    /**
93
     * @param Block
94
     */
95
    public function addParent(Block $parent)
96
    {
97
        $this->parents[] = $parent;
98
    }
99
100
    /**
101
     * @return bool
102
     */
103
    public function isUnreachable()
104
    {
105
        return $this->unreachable;
106
    }
107
}
108