Test Setup Failed
Push — master ( 009624...c15db0 )
by Chris
48s
created

KeyContainer::tagKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Carnage\EncryptedColumn\Container;
4
5
use Carnage\EncryptedColumn\ValueObject\Key;
6
use Psr\Container\ContainerInterface;
7
8
final class KeyContainer implements ContainerInterface
9
{
10
    /**
11
     * @var array
12
     */
13
    private $keys = [];
14
15
    public function addKey(Key $key)
16
    {
17
        $this->keys[$key->getIdentifier()->toString()] = $key;
18
    }
19
20
    public function tagKey($tag, $id)
21
    {
22
        $this->keys[$tag] = $this->keys[$id];
23
    }
24
25
    public function get($id)
26
    {
27
        if (!$this->has($id)) {
28
            throw NotFoundException::serviceNotFoundInContainer($id, $this->keys);
29
        }
30
31
        return $this->keys[$id];
32
    }
33
34
    public function has($id): bool
35
    {
36
        return isset($this->keys[$id]);
37
    }
38
}
39