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
Branch 1.0 (53c4b5)
by Quim
03:22
created

WildcardDispatcher::handle()   B

Complexity

Conditions 6
Paths 18

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
ccs 19
cts 19
cp 1
rs 8.5907
cc 6
eloc 17
nc 18
nop 1
crap 6
1
<?php
2
namespace QuimCalpe\Router\Dispatchers;
3
4
use QuimCalpe\Router\Route\ParsedRoute;
5
use RuntimeException;
6
7
class WildcardDispatcher implements DispatcherInterface
8
{
9
    /**
10
     * @param ParsedRoute $route
11
     * @return string
12
     *
13
     * @throws RuntimeException
14
     */
15 5
    public function handle(ParsedRoute $route)
16
    {
17 5
        $controller = $route->controller();
18 5
        $rawParams = $route->params();
19 5
        foreach ($rawParams as $param => $value) {
20 2
            if (strpos($controller, "{".$param."}") !== false) {
21 1
                $controller = str_replace("{".$param."}", ucfirst($value), $controller);
22 1
                unset($rawParams[$param]);
23 1
            }
24 5
        }
25 5
        $segments = explode("::", $controller);
26 5
        $controller = $segments[0];
27 5
        $action = count($segments) > 1 ? $segments[1] : "index";
28 5
        if (method_exists($controller, $action)) {
29 4
            $params = [];
30 4
            if (count($rawParams)) {
31 2
                $params[] = $rawParams;
32 2
            }
33 4
            return call_user_func_array([new $controller, $action], $params);
34
        } else {
35 1
            throw new RuntimeException("No method {$action} in controller {$segments[0]}");
36
        }
37
    }
38
}
39