Passed
Branch master (6982d9)
by Ivan
02:35
created

MutableContainer::reset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\Navigation;
6
7
use Everlution\Navigation\Item\ItemInterface;
8
9
/**
10
 * Class MutableContainer.
11
 *
12
 * @author Ivan Barlog <[email protected]>
13
 */
14
abstract class MutableContainer implements MutableContainerInterface
15
{
16
    /** @var ItemInterface[] */
17
    private $items = [];
18
19
    public function add(ItemInterface $item): void
20
    {
21
        $this->items[get_class($item)] = $item;
22
    }
23
24
    /**
25
     * @return \Everlution\Navigation\Item\ItemInterface[]
26
     */
27
    public function getItems(): array
28
    {
29
        return $this->items;
30
    }
31
32
    public function get(string $name): ItemInterface
33
    {
34
        return $this->items[$name];
35
    }
36
37
    public function reset(): void
38
    {
39
        $this->items = [];
40
    }
41
}
42