Test Failed
Push — master ( 9196b6...62d342 )
by Ivan
02:35
created

RootNavigationItem::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Everlution\Navigation;
6
7
/**
8
 * Interface Navigation.
9
 * @author Ivan Barlog <[email protected]>
10
 */
11
class RootNavigationItem implements Item
12
{
13
    /**
14
     * @return string
15
     */
16
    public function getLabel(): string
17
    {
18
        return 'navigation root';
19
    }
20
21
    /** @var Item[] */
22
    private $children;
23
24
    /**
25
     * @return array
26
     */
27
    public function getChildren(): array
28
    {
29
        return $this->children;
30
    }
31
32
    /**
33
     * @param Item $item
34
     * @return Item
35
     */
36
    public function addChild(Item $item)
37
    {
38
        $this->children[] = $item;
39
40
        return $this;
41
    }
42
43
    /**
44
     * @param Item $parent
45
     * @return Item
46
     * @throws \Exception
47
     */
48
    public function setParent(Item $parent)
49
    {
50
        throw new \Exception(sprintf('%s cannot have parent', self::class));
51
    }
52
53
    /**
54
     * @return Item|null
55
     */
56
    public function getParent()
57
    {
58
        return null;
59
    }
60
}
61