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

ItemContainer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addItem() 0 3 1
A get() 0 7 2
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