Total Complexity | 5 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
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 |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * @return RequirementsProviderInterface[] |
||
36 | */ |
||
37 | 1 | public function all(): array |
|
40 | } |
||
41 | } |
||
42 |