Completed
Push — master ( e8bfce...313e31 )
by Arnaud
13s queued 11s
created

Menu::getItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace LAG\AdminBundle\Menu;
4
5
use LAG\AdminBundle\Configuration\MenuConfiguration;
6
7
class Menu
8
{
9
    /**
10
     * @var MenuItem[]
11
     */
12
    private $items = [];
13
14
    /**
15
     * @var string
16
     */
17
    private $name;
18
19
    /**
20
     * @var MenuConfiguration
21
     */
22
    private $configuration;
23
24
    /**
25
     * Menu constructor.
26
     */
27
    public function __construct(string $name, MenuConfiguration $configuration)
28
    {
29
        $this->name = $name;
30
        $this->configuration = $configuration;
31
    }
32
33
    public function addItem(MenuItem $item)
34
    {
35
        $this->items[] = $item;
36
    }
37
38
    public function removeItem(int $position)
39
    {
40
        unset($this->items[$position]);
41
    }
42
43
    public function clear(): void
44
    {
45
        $this->items = [];
46
    }
47
48
    /**
49
     * @return MenuItem[]
50
     */
51
    public function getItems(): array
52
    {
53
        return $this->items;
54
    }
55
56
    public function getName(): string
57
    {
58
        return $this->name;
59
    }
60
61
    public function get(string $parameter)
62
    {
63
        return $this->configuration->getParameter($parameter);
64
    }
65
66
    public function getConfiguration(): MenuConfiguration
67
    {
68
        return $this->configuration;
69
    }
70
}
71