Container.php$0 ➔ get()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RemotelyLiving\PHPCommandBus\Tests\Stubs;
6
7
use Psr\Container\ContainerInterface;
8
use Psr\Container\NotFoundExceptionInterface;
9
10
class Container implements ContainerInterface
11
{
12
    private array $services;
13
14
    public function __construct(array $services = [])
15
    {
16
        $this->services = $services;
17
    }
18
19
    public function get($id)
20
    {
21
        if ($this->has($id)) {
22
            return $this->services[$id];
23
        }
24
25
        throw new class ('Not found') extends \Exception implements NotFoundExceptionInterface {
26
        };
27
    }
28
29
    public function has($id): bool
30
    {
31
        return isset($this->services[$id]);
32
    }
33
}
34