| Total Complexity | 5 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | class ServiceProvider implements ServiceProviderInterface |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var array<string, callable> |
||
| 17 | */ |
||
| 18 | protected array $factories; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param array<string, callable> $factories |
||
| 22 | */ |
||
| 23 | public function __construct(array $factories) |
||
| 26 | } |
||
| 27 | |||
| 28 | public function get(string $id): mixed |
||
| 29 | { |
||
| 30 | if (! array_key_exists($id, $this->factories)) { |
||
| 31 | throw new ServiceNotFoundException(sprintf('Service %s not found', $id)); |
||
| 32 | } |
||
| 33 | |||
| 34 | return $this->factories[$id](); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function has(string $id): bool |
||
| 40 | } |
||
| 41 | |||
| 42 | public function getProvidedServices(): array |
||
| 45 | } |
||
| 46 | } |
||
| 47 |