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

Menu   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 62
ccs 0
cts 32
cp 0
rs 10
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A addItem() 0 3 1
A get() 0 3 1
A getName() 0 3 1
A __construct() 0 4 1
A getItems() 0 3 1
A getConfiguration() 0 3 1
A clear() 0 3 1
A removeItem() 0 3 1
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