Passed
Push — master ( 70c68f...c76078 )
by Alexander
06:58
created

Container::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
4
namespace Yiisoft\Router\Tests\Support;
5
6
use Psr\Container\ContainerInterface;
7
8
class Container implements ContainerInterface
9
{
10
    private array $instances;
11
12
    public function __construct(array $instances)
13
    {
14
        $this->instances = $instances;
15
    }
16
17
    public function get($id)
18
    {
19
        if ($this->has($id)) {
20
            return $this->instances[$id];
21
        }
22
23
        throw new NotFoundException("$id was not found in container");
24
    }
25
26
    public function has($id)
27
    {
28
        return array_key_exists($id, $this->instances);
29
    }
30
}
31