Passed
Pull Request — master (#5)
by Ivan
01:48
created

RootNode   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 33
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addChild() 0 4 1
A hasChildren() 0 4 1
A getChildren() 0 4 1
A has() 0 4 1
A get() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\Navigation\Builder;
6
7
/**
8
 * Class RootNode.
9
 *
10
 * @author Ivan Barlog <[email protected]>
11
 */
12
class RootNode
13
{
14
    /** @var ParentNode[] */
15
    private $children = [];
16
17
    public function addChild(ParentNode $item): void
18
    {
19
        $this->children[get_class($item->getItem())] = $item;
20
    }
21
22
    public function hasChildren(): bool
23
    {
24
        return false === empty($this->children);
25
    }
26
27
    /**
28
     * @return ParentNode[]
29
     */
30
    public function getChildren(): array
31
    {
32
        return $this->children;
33
    }
34
35
    public function has(string $name): bool
36
    {
37
        return array_key_exists($name, $this->children);
38
    }
39
40
    public function get(string $name): ParentNode
41
    {
42
        return $this->children[$name];
43
    }
44
}
45