| Conditions | 6 |
| Paths | 6 |
| Total Lines | 29 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function prepandRoutes(IRouter $router, array $routes): void |
||
| 24 | { |
||
| 25 | if (empty($routes)) { |
||
| 26 | return; |
||
| 27 | } |
||
| 28 | |||
| 29 | if (!($router instanceof \Traversable) || !($router instanceof \ArrayAccess)) { |
||
| 30 | throw new ApiRouteWrongRouterException(sprintf( |
||
| 31 | 'ApiRoutesResolver can not add ApiRoutes to your router. Use for example %s instead', |
||
| 32 | RouteList::class |
||
| 33 | )); |
||
| 34 | } |
||
| 35 | |||
| 36 | $user_routes = $this->findAndDestroyUserRoutes($router); |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Add ApiRoutes first |
||
| 40 | */ |
||
| 41 | foreach ($routes as $route) { |
||
| 42 | $router[] = $route; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * User routes on second place |
||
| 47 | */ |
||
| 48 | foreach ($user_routes as $route) { |
||
| 49 | $router[] = $route; |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 71 |