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

ResponderStorage::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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