Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 3.2098 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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 | } |
||
47 |