Total Complexity | 5 |
Total Lines | 24 |
Duplicated Lines | 0 % |
Coverage | 70% |
Changes | 5 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
12 | final class Gii implements GiiInterface |
||
13 | { |
||
14 | /** |
||
15 | * @param array<string, GeneratorInterface|GeneratorProxy> $proxies |
||
16 | */ |
||
17 | 8 | public function __construct(private array $proxies) |
|
19 | 8 | } |
|
20 | |||
21 | public function addGenerator(GeneratorInterface $generator): void |
||
22 | { |
||
23 | $this->proxies[$generator::getId()] = new GeneratorProxy(fn () => $generator, $generator::class); |
||
24 | } |
||
25 | |||
26 | 1 | public function getGenerator(string $id): GeneratorInterface |
|
27 | { |
||
28 | 1 | return isset($this->proxies[$id]) |
|
29 | ? $this->proxies[$id]->loadGenerator() |
||
30 | 1 | : throw new GeneratorNotFoundException('Generator "' . $id . '" not found'); |
|
31 | } |
||
32 | |||
33 | 4 | public function getGenerators(): array |
|
36 | } |
||
37 | } |
||
38 |