RequirementsProviderRegistry   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 32
ccs 11
cts 11
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A all() 0 3 1
A add() 0 3 1
A get() 0 7 2
1
<?php
2
3
namespace LAG\SmokerBundle\Url\Requirements\Registry;
4
5
use LAG\SmokerBundle\Contracts\Requirements\Provider\RequirementsProviderInterface;
6
use LAG\SmokerBundle\Exception\Exception;
7
8
class RequirementsProviderRegistry
9
{
10
    protected $registry = [];
11
12 1
    public function add(string $name, RequirementsProviderInterface $provider): void
13
    {
14 1
        $this->registry[$name] = $provider;
15 1
    }
16
17
    /**
18
     * @throws Exception
19
     */
20 1
    public function get(string $name): RequirementsProviderInterface
21
    {
22 1
        if (!$this->has($name)) {
23 1
            throw new Exception('The requirements provider "'.$name.'" is not registered');
24
        }
25
26 1
        return $this->registry[$name];
27
    }
28
29 1
    public function has(string $name): bool
30
    {
31 1
        return key_exists($name, $this->registry);
32
    }
33
34
    /**
35
     * @return RequirementsProviderInterface[]
36
     */
37 1
    public function all(): array
38
    {
39 1
        return $this->registry;
40
    }
41
}
42