| Conditions | 4 |
| Paths | 5 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4.128 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | 4 | public function create(string $name, array $config): Dictionary |
|
| 22 | 4 | { |
|
| 23 | 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 | 1 | ||
| 30 | $service = $this->container->get($config['service']); |
||
| 31 | 1 | $callable = [$service]; |
|
| 32 | |||
| 33 | if (isset($config['method'])) { |
||
| 34 | $callable[] = $config['method']; |
||
| 35 | } |
||
| 36 | |||
| 37 | if (!\is_callable($callable)) { |
||
| 38 | 1 | throw new \InvalidArgumentException(\sprintf( |
|
| 39 | 1 | 'You must provide a valid callable for the dictionary named "%s".', |
|
| 40 | $name |
||
| 41 | 1 | )); |
|
| 42 | 1 | } |
|
| 43 | |||
| 44 | return new Dictionary\Invokable($name, $callable); |
||
| 45 | 1 | } |
|
| 52 |