Completed
Push — master ( 3c2b8e...8f2461 )
by Дмитрий
07:09
created

Block   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
dl 0
loc 98
ccs 12
cts 21
cp 0.5714
rs 10
c 0
b 0
f 0
wmc 8
lcom 2
cbo 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A addChildren() 0 4 1
A setExit() 0 4 1
A getChildren() 0 4 1
A getExit() 0 4 1
A getId() 0 4 1
A addParent() 0 4 1
A isUnreachable() 0 4 1
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 52
    public function __construct($id, $unreachable = false)
47
    {
48 52
        $this->id = $id;
49 52
        $this->unreachable = $unreachable;
50 52
    }
51
52
    /**
53
     * @param AbstractNode $node
54
     */
55 48
    public function addChildren(AbstractNode $node)
56
    {
57 48
        $this->children[] = $node;
58 48
    }
59
60
    /**
61
     * @param Block $exit
62
     */
63 40
    public function setExit(Block $exit)
64
    {
65 40
        $this->exit = $exit;
66 40
    }
67
68
    /**
69
     * @return AbstractNode[]
70
     */
71 1
    public function getChildren()
72
    {
73 1
        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