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 ( 5c5c4b...19a2b9 )
by Quim
02:25
created

RequestResponseDispatcher   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 12 3
1
<?php
2
namespace QuimCalpe\Router\Dispatcher;
3
4
use QuimCalpe\Router\Route\ParsedRoute;
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\HttpFoundation\Response;
7
use RuntimeException;
8
9
class RequestResponseDispatcher implements DispatcherInterface
10
{
11
    /**
12
     * @var Request
13
     */
14
    private $request;
15
16
    /**
17
     * @param Request $request
18
     */
19 5
    public function __construct(Request $request)
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
20
    {
21 5
        $this->request = $request;
22 5
    }
23
24
    /**
25
     * @param ParsedRoute $route
26
     * @return Response
27
     *
28
     * @throws RuntimeException
29
     */
30 5
    public function handle(ParsedRoute $route)
31
    {
32 5
        $segments = explode("::", $route->controller());
33 5
        $controller = $segments[0];
34 5
        $action = count($segments) > 1 ? $segments[1] : "index";
35 5
        if (method_exists($controller, $action)) {
36 4
            $params = [$this->request, new Response(), $route->params()];
37 4
            return call_user_func_array([new $controller(), $action], $params);
38
        } else {
39 1
            throw new RuntimeException("No method {$action} in controller {$segments[0]}");
40
        }
41
    }
42
}
43