Node   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 6
eloc 12
c 3
b 1
f 0
dl 0
loc 66
ccs 17
cts 17
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getLeft() 0 3 1
A __construct() 0 5 1
A getItem() 0 3 1
A setRight() 0 3 1
A setLeft() 0 3 1
A getRight() 0 3 1
1
<?php
2
3
4
namespace Hexogen\KDTree;
5
6
use Hexogen\KDTree\Interfaces\NodeInterface;
7
use Hexogen\KDTree\Interfaces\ItemInterface;
8
9
class Node implements NodeInterface
10
{
11
    /**
12
     * @var ItemInterface
13
     */
14
    private $item;
15
16
    /**
17
     * @var NodeInterface|null
18
     */
19
    private $left;
20
21
    /**
22
     * @var NodeInterface|null
23
     */
24
    private $right;
25
26
    /**
27
     * Node constructor.
28
     * @param ItemInterface $item
29
     */
30 96
    public function __construct(ItemInterface $item)
31
    {
32 96
        $this->item = $item;
33 96
        $this->left = null;
34 96
        $this->right = null;
35 96
    }
36
37
    /**
38
     * @return ItemInterface get item from the node
39
     */
40 72
    public function getItem() : ItemInterface
41
    {
42 72
        return $this->item;
43
    }
44
45
    /**
46
     * @param NodeInterface $node set right node
47
     */
48 75
    public function setRight(NodeInterface $node): void
49
    {
50 75
        $this->right = $node;
51 75
    }
52
53
    /**
54
     * @param NodeInterface $node set left node
55
     */
56 78
    public function setLeft(NodeInterface $node): void
57
    {
58 78
        $this->left = $node;
59 78
    }
60
61
    /**
62
     * @return NodeInterface|null get right node
63
     */
64 69
    public function getRight(): ?NodeInterface
65
    {
66 69
        return $this->right;
67
    }
68
69
    /**
70
     * @return NodeInterface|null get left node
71
     */
72 69
    public function getLeft(): ?NodeInterface
73
    {
74 69
        return $this->left;
75
    }
76
}
77