| Total Complexity | 6 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Coverage | 63.64% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final class Iterator implements Factory |
||
| 13 | { |
||
| 14 | public function __construct(private readonly ContainerInterface $container) {} |
||
| 15 | |||
| 16 | /** |
||
| 17 | * {@inheritdoc} |
||
| 18 | * |
||
| 19 | * @throw InvalidArgumentException if there is some problem with the config. |
||
| 20 | 4 | */ |
|
| 21 | public function create(string $name, array $config): Dictionary |
||
| 22 | 4 | { |
|
| 23 | 4 | if (!isset($config['service'])) { |
|
| 24 | throw new \InvalidArgumentException(\sprintf( |
||
| 25 | 'The "service" config key must be set for the dictionary named "%s".', |
||
| 26 | $name |
||
| 27 | )); |
||
| 28 | } |
||
| 29 | |||
| 30 | 1 | $service = $this->container->get($config['service']); |
|
| 31 | |||
| 32 | 1 | if (!$service instanceof \Traversable) { |
|
| 33 | throw new \InvalidArgumentException(\sprintf( |
||
| 34 | 'You must provide a valid instance of Traversable for the dictionary named "%s".', |
||
| 35 | $name |
||
| 36 | )); |
||
| 37 | } |
||
| 38 | |||
| 39 | 1 | return new Dictionary\Iterator($name, $service); |
|
| 40 | } |
||
| 41 | 1 | ||
| 42 | public function supports(array $config): bool |
||
| 45 | } |
||
| 46 | } |
||
| 47 |