Passed
Push — master ( 31c7b0...a544c9 )
by Alexander
01:28
created

SimpleContainer::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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