Test Failed
Push — master ( 992a11...749776 )
by Derek Stephen
14:00
created

Router::removeRoute()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 3
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Bone\Router;
4
5
use Bone\Http\RouterInterface;
6
use League\Route\Route;
7
use League\Route\RouteGroup;
8
use League\Route\Router as LeagueRouter;
9
use Psr\Http\Message\ResponseInterface;
10
use Psr\Http\Message\ServerRequestInterface;
11
use Psr\Http\Server\RequestHandlerInterface;
12
13
class Router extends LeagueRouter implements RequestHandlerInterface, RouterInterface
14
{
15
    /**
16
     * @return Route[]
17
     */
18
    public function getRoutes(): array
19
    {
20
        return $this->routes;
21
    }
22
23
    /**
24
     * @return RouteGroup[]
25
     */
26
    public function getGroups(): array
27
    {
28
        return $this->groups;
29
    }
30
31
    /**
32
     * @param Route $route
33
     */
34
    public function removeRoute(Route $routeToRemove): void
35
    {
36
        foreach ($this->routes as $index => $route) {
37
            if ($route === $routeToRemove) {
38
                unset($this->routes[$index]);
39
            }
40
        }
41
    }
42
43
    /**
44
     * @param ServerRequestInterface $request
45
     * @return ResponseInterface
46
     */
47
    public function handle(ServerRequestInterface $request): ResponseInterface
48
    {
49
        return $this->dispatch($request);
50
    }
51
}
52