Completed
Pull Request — master (#90)
by Arnaud
02:15
created

ResponderStorage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 23
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A get() 0 8 2
A has() 0 4 1
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