VersionedContainer::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2
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