MutableContainer::get()   A
last analyzed

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 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