Passed
Pull Request — master (#6)
by
unknown
02:09
created

MutableContainer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getItems() 0 3 1
A reset() 0 3 1
A get() 0 3 1
A add() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\Navigation\Container;
6
7
use Everlution\Navigation\Item\ItemInterface;
8
use Everlution\Navigation\Container\MutableContainerInterface;
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[get_class($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 $name): ItemInterface
34
    {
35
        return $this->items[$name];
36
    }
37
38
    public function reset(): void
39
    {
40
        $this->items = [];
41
    }
42
}
43