MutableContainer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 6
dl 0
loc 26
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A reset() 0 3 1
A getItems() 0 3 1
A get() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\Navigation;
6
7
use Everlution\Navigation\Item\ItemInterface;
8
use Everlution\Navigation\Helper\ItemHelper;
9
10
/**
11
 * Class MutableContainer.
12
 *
13
 * @author Ivan Barlog <[email protected]>
14
 */
15
abstract class MutableContainer implements MutableContainerInterface
16
{
17
    /** @var ItemInterface[] */
18
    private $items = [];
19
20
    public function add(ItemInterface $item): void
21
    {
22
        $this->items[ItemHelper::getIdentifier($item)] = $item;
23
    }
24
25
    /**
26
     * @return \Everlution\Navigation\Item\ItemInterface[]
27
     */
28
    public function getItems(): array
29
    {
30
        return $this->items;
31
    }
32
33
    public function get(string $identifier): ItemInterface
34
    {
35
        return $this->items[$identifier];
36
    }
37
38
    public function reset(): void
39
    {
40
        $this->items = [];
41
    }
42
}
43