Container   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

5 Methods

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