| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 42 | public function resolve(ContainerInterface $container) |
||
| 43 | { |
||
| 44 | try { |
||
| 45 | $result = $container->get($this->id); |
||
| 46 | } catch (\Throwable $t) { |
||
| 47 | if ($this->optional) { |
||
| 48 | return null; |
||
| 49 | } |
||
| 50 | throw $t; |
||
| 51 | } |
||
| 52 | |||
| 53 | if (!$result instanceof $this->class) { |
||
| 54 | throw new InvalidConfigException(strtr('Container returned incorrect type for service {s}, expected {e}, got {r}', [ |
||
| 55 | '{s}' => $this->id, |
||
| 56 | '{e}' => $this->class, |
||
| 57 | '{r}' => get_class($result) |
||
| 58 | ])); |
||
| 59 | } |
||
| 60 | return $result; |
||
| 61 | } |
||
| 63 |