| Conditions | 7 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 56 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | public function __invoke(ContainerInterface $container): RouterInterface |
||
| 19 | { |
||
| 20 | $factory = $this->engineFactory; |
||
| 21 | /* @var $router RouterInterface */ |
||
| 22 | $router = $factory($container); |
||
| 23 | foreach ($this->routes as $route) { |
||
| 24 | if ($route instanceof Route) { |
||
| 25 | $router->addRoute($route); |
||
| 26 | } elseif (\is_array($route) && \count($route) === 2 && \is_string($route[0]) && \is_callable($route[1])) { |
||
| 27 | $router->addGroup($route[0], $route[1]); |
||
| 28 | } else { |
||
| 29 | throw new \InvalidArgumentException('Routes should be eithe instances of Route or group arrays'); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | return $router; |
||
| 33 | } |
||
| 35 |