| Conditions | 5 |
| Paths | 8 |
| Total Lines | 18 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5.0144 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | 1 | public function __invoke(ContainerInterface $container): RouterInterface |
|
| 26 | { |
||
| 27 | 1 | $factory = $this->engineFactory; |
|
| 28 | /* @var $router RouterInterface */ |
||
| 29 | 1 | $router = $factory(); |
|
| 30 | 1 | if (!$router->hasContainer()) { |
|
| 31 | 1 | $router = $router->withContainer($container); |
|
| 32 | } |
||
| 33 | 1 | foreach ($this->routes as $route) { |
|
| 34 | 1 | if ($route instanceof Route) { |
|
| 35 | 1 | $router->addRoute($route); |
|
| 36 | 1 | } elseif ($route instanceof Group) { |
|
| 37 | 1 | $router->addGroup($route); |
|
| 38 | } else { |
||
| 39 | throw new InvalidArgumentException('Routes should be either instances of Route or Group'); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | 1 | return $router; |
|
| 43 | } |
||
| 45 |