ItemContainer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 16
rs 10
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
 *
12
 * @author Ivan Barlog <[email protected]>
13
 */
14
class ItemContainer implements ItemContainerInterface
15
{
16
    private $items = [];
17
18
    public function addItem(string $name, ItemInterface $item): void
19
    {
20
        $this->items[$name] = $item;
21
    }
22
23
    public function get(string $name): ItemInterface
24
    {
25
        if (false === array_key_exists($name, $this->items)) {
26
            throw new ItemNotRegisteredException($name);
27
        }
28
29
        return $this->items[$name];
30
    }
31
}
32