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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 41
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 12 3
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