Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| DefinitionCollection | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| hydrate | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
| hasKey | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace pvc\container\defs; |
| 6 | |
| 7 | use ArrayIterator; |
| 8 | use pvc\interfaces\container\DefinitionInterface; |
| 9 | |
| 10 | /** |
| 11 | * @extends \IteratorIterator<string, DefinitionInterface, ArrayIterator> |
| 12 | */ |
| 13 | class DefinitionCollection extends \IteratorIterator |
| 14 | { |
| 15 | public function __construct() |
| 16 | { |
| 17 | /** @var ArrayIterator<string, DefinitionInterface> $iterator */ |
| 18 | $iterator = new ArrayIterator(); |
| 19 | parent::__construct($iterator); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * hydrate |
| 24 | * @param array<DefinitionInterface> $definitions |
| 25 | * |
| 26 | * @return void |
| 27 | */ |
| 28 | public function hydrate(array $definitions): void |
| 29 | { |
| 30 | foreach($definitions as $definition) { |
| 31 | /** |
| 32 | * phpstan does not know that the inner iterator is an array iterator and so it does not know about |
| 33 | * offsetSet |
| 34 | * @phpstan-ignore-next-line |
| 35 | */ |
| 36 | $this->getInnerIterator()->offsetSet($definition->getAlias(), $definition); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * hasKey |
| 42 | * @param string $key |
| 43 | * clumsy, but phpdi needs this because it will not try and recursively resolve arguments for constructors |
| 44 | * and method calls |
| 45 | * @return bool |
| 46 | */ |
| 47 | public function hasKey(string $key): bool |
| 48 | { |
| 49 | /** |
| 50 | * phpstan does not know that the inner iterator is an array iterator and so it does not know about |
| 51 | * offsetExists |
| 52 | * @phpstan-ignore-next-line |
| 53 | */ |
| 54 | return $this->getInnerIterator()->offsetExists($key); |
| 55 | } |
| 56 | } |