GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 7d7833...51b1e6 )
by Patrique
01:17
created

Router::addRoute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Patoui\Router;
6
7
use Psr\Http\Message\ServerRequestInterface;
8
9
class Router
10
{
11
    /** @var array<Routable> */
12
    private array $routes;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
13
14
    public function __construct()
15
    {
16
        $this->routes = [];
17
    }
18
19
    public function addRoute(Routable $routable): void
20
    {
21
        $this->routes[] = $routable;
22
    }
23
24
    /**
25
     * @return array<Routable>
26
     */
27
    public function getRoutes(): array
28
    {
29
        return $this->routes;
30
    }
31
32
    /**
33
     * @param  ServerRequestInterface $serverRequest
34
     * @return Routable
35
     * @throws RouteNotFoundException
36
     */
37
    public function resolve(ServerRequestInterface $serverRequest)
38
    {
39
        foreach ($this->routes as $route) {
40
            if ($route->isHttpVerbAndPathAMatch($serverRequest->getMethod(), $serverRequest->getRequestTarget())) {
41
                return $route;
42
            }
43
        }
44
45
        throw new RouteNotFoundException('Route not found');
46
    }
47
}
48