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 ( 19a2b9...aa694f )
by Quim
02:16
created

PSR7Dispatcher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4286
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
namespace QuimCalpe\Router\Dispatcher;
3
4
use QuimCalpe\Router\Route\ParsedRoute;
5
use Psr\Http\Message\ServerRequestInterface;
6
use Psr\Http\Message\ResponseInterface;
7
use RuntimeException;
8
9
class PSR7Dispatcher implements DispatcherInterface
10
{
11
    /**
12
     * @var ServerRequestInterface
13
     */
14
    private $request;
15
16
    /**
17
     * @var ResponseInterface
18
     */
19
    private $response;
20
21
    /**
22
     * @param ServerRequestInterface $request
23
     * @param ResponseInterface $response
24
     */
25 4
    public function __construct(ServerRequestInterface $request, ResponseInterface $response)
26
    {
27 4
        $this->request = $request;
28 4
        $this->response = $response;
29 4
    }
30
31
    /**
32
     * @param ParsedRoute $route
33
     * @return Response
34
     *
35
     * @throws RuntimeException
36
     */
37 4
    public function handle(ParsedRoute $route)
38
    {
39 4
        $segments = explode("::", $route->controller());
40 4
        $controller = $segments[0];
41 4
        $action = count($segments) > 1 ? $segments[1] : "index";
42 4
        if (method_exists($controller, $action)) {
43 3
            $params = [$this->request, $this->response, $route->params()];
44 3
            return call_user_func_array([new $controller(), $action], $params);
45
        } else {
46 1
            throw new RuntimeException("No method {$action} in controller {$segments[0]}");
47
        }
48
    }
49
}
50