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

Container   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 21
rs 10

3 Methods

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