Passed
Push — master ( f24ea2...036951 )
by Ivan
03:16
created

ItemContainer::addItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\NavigationBundle\Bridge\Item\Container;
6
7
use Everlution\Navigation\Item\ItemInterface;
8
9
/**
10
 * Class ItemContainer.
11
 * @author Ivan Barlog <[email protected]>
12
 */
13
class ItemContainer implements ItemContainerInterface
14
{
15
    private $items = [];
16
17
    public function addItem(string $name, ItemInterface $item): void
18
    {
19
        $this->items[$name] = $item;
20
    }
21
22
    public function get(string $name): ItemInterface
23
    {
24
        if (false === array_key_exists($name, $this->items)) {
25
            throw new ItemNotRegisteredException($name);
26
        }
27
28
        return $this->items[$name];
29
    }
30
}
31