ControlNode::addSubNode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace kalanis\kw_tree_controls;
4
5
6
use kalanis\kw_forms\Controls\AControl;
7
use kalanis\kw_tree\Essentials\FileNode;
8
9
10
/**
11
 * Class ControlNode
12
 * @package kalanis\kw_tree_control
13
 * File in directory (could be directory too)
14
 * Join FileNode and its control
15
 */
16
class ControlNode
17
{
18
    protected ?FileNode $node = null;
19
    protected ?AControl $control = null;
20
    /** @var ControlNode[] */
21
    protected array $subNodes = [];
22
23 6
    public function setNode(?FileNode $node = null): self
24
    {
25 6
        $this->node = $node;
26 6
        return $this;
27
    }
28
29 3
    public function getNode(): ?FileNode
30
    {
31 3
        return $this->node;
32
    }
33
34 6
    public function setControl(?AControl $control = null): self
35
    {
36 6
        $this->control = $control;
37 6
        return $this;
38
    }
39
40 6
    public function getControl(): ?AControl
41
    {
42 6
        return $this->control;
43
    }
44
45 6
    public function addSubNode(ControlNode $node): self
46
    {
47 6
        $this->subNodes[] = $node;
48 6
        return $this;
49
    }
50
51
    /**
52
     * @return ControlNode[]
53
     */
54 6
    public function getSubNodes(): array
55
    {
56 6
        return $this->subNodes;
57
    }
58
}
59