VersionedContainer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 28
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A get() 0 8 2
A has() 0 4 1
1
<?php
2
3
namespace Carnage\EncryptedColumn\Container;
4
5
use Psr\Container\ContainerInterface;
6
7
final class VersionedContainer implements ContainerInterface
8
{
9
    /**
10
     * @var VersionedInterface[]
11
     */
12
    private $services;
13
14 5
    public function __construct(VersionedInterface ...$services)
15
    {
16 5
        foreach ($services as $service) {
17 5
            $this->services[$service->getIdentifier()->toString()] = $service;
18
        }
19 5
    }
20
21 6
    public function get($id): VersionedInterface
22
    {
23 6
        if (!$this->has($id)) {
24
            throw NotFoundException::serviceNotFoundInContainer($id, $this->services);
25
        }
26
27 6
        return $this->services[$id];
28
    }
29
30 6
    public function has($id): bool
31
    {
32 6
        return isset($this->services[$id]);
33
    }
34
}
35