Completed
Pull Request — master (#90)
by Arnaud
03:09 queued 01:17
created

ResponderStorage::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
3
namespace LAG\AdminBundle\Responder\Storage;
4
5
use LAG\AdminBundle\Responder\ResponderInterface;
6
7
class ResponderStorage
8
{
9
    private $responders = [];
10
    
11
    public function add($serviceId, ResponderInterface $responder)
12
    {
13
        $this->responders[$serviceId] = $responder;
14
    }
15
    
16
    public function get($serviceId)
17
    {
18
        if (!$this->has($serviceId)) {
19
            throw new \Exception('Invalid responder service id "'.$serviceId.'"');
20
        }
21
    
22
        return $this->responders[$serviceId];
23
    }
24
    
25
    public function has($serviceId)
26
    {
27
        return key_exists($serviceId, $this->responders);
28
    }
29
}
30