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