Passed
Push — master ( 3d457e...75df93 )
by Ivan
01:49
created

OrderedContainer::ascending()   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 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\Navigation;
6
7
use Everlution\Navigation\Item\ItemInterface;
8
use Everlution\Navigation\Item\SortableInterface;
9
10
/**
11
 * Class OrderedContainer.
12
 *
13
 * @author Ivan Barlog <[email protected]>
14
 */
15
class OrderedContainer implements ContainerInterface
16
{
17
    /** @var ContainerInterface */
18
    private $container;
19
    /** @var ItemInterface[] */
20
    private $items;
21
22
    public function __construct(ContainerInterface $container)
23
    {
24
        $this->container = $container;
25
    }
26
27
    /**
28
     * @return ItemInterface[]
29
     */
30
    public function getItems(): array
31
    {
32
        if (empty($this->items)) {
33
            $this->items = $this->container->getItems();
34
        }
35
36
        return $this->items;
37
    }
38
39
    public function get(string $identifier): ItemInterface
40
    {
41
        return $this->items[$identifier];
42
    }
43
}
44