Container::has()
last analyzed

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
nc 1
nop 1
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