| Total Complexity | 6 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Coverage | 71.43% |
| Changes | 5 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 9 | final class Gii implements GiiInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @param array<string, GeneratorInterface|GeneratorProxy> $proxies |
||
| 13 | * @param array<string, GeneratorInterface> $instances |
||
| 14 | */ |
||
| 15 | 8 | public function __construct( |
|
| 16 | private readonly array $proxies, |
||
| 17 | private array $instances, |
||
| 18 | ) |
||
| 19 | { |
||
| 20 | 8 | } |
|
| 21 | |||
| 22 | public function addGenerator(GeneratorInterface $generator): void |
||
| 25 | } |
||
| 26 | |||
| 27 | 1 | public function getGenerator(string $id): GeneratorInterface |
|
| 28 | { |
||
| 29 | 1 | if (isset($this->instances[$id])) { |
|
| 30 | return $this->instances[$id]; |
||
| 31 | } |
||
| 32 | 1 | return isset($this->proxies[$id]) |
|
| 33 | ? $this->proxies[$id]->loadGenerator() |
||
| 34 | 1 | : throw new GeneratorNotFoundException('Generator "' . $id . '" not found'); |
|
| 35 | } |
||
| 36 | |||
| 37 | 4 | public function getGenerators(): array |
|
| 42 | 4 | ]; |
|
| 43 | } |
||
| 45 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: