| Total Complexity | 5 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class RequirementsProviderRegistry |
||
| 9 | { |
||
| 10 | protected $registry = []; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @param string $name |
||
| 14 | * @param RequirementsProviderInterface $provider |
||
| 15 | */ |
||
| 16 | public function add(string $name, RequirementsProviderInterface $provider): void |
||
| 17 | { |
||
| 18 | $this->registry[$name] = $provider; |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param string $name |
||
| 23 | * |
||
| 24 | * @return RequirementsProviderInterface |
||
| 25 | * |
||
| 26 | * @throws Exception |
||
| 27 | */ |
||
| 28 | public function get(string $name): RequirementsProviderInterface |
||
| 29 | { |
||
| 30 | if (!$this->has($name)) { |
||
| 31 | throw new Exception('The requirements provider "'.$name.'" is not registered'); |
||
| 32 | } |
||
| 33 | |||
| 34 | return $this->registry[$name]; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param string $name |
||
| 39 | * |
||
| 40 | * @return bool |
||
| 41 | */ |
||
| 42 | public function has(string $name): bool |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @return RequirementsProviderInterface[] |
||
| 49 | */ |
||
| 50 | public function all(): array |
||
| 53 | } |
||
| 54 | } |
||
| 55 |