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.

SlimRouterAdapter::generateRelativePath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 9
ccs 0
cts 9
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace JDolba\SlimHttpSmokeTesting\RouterAdapter;
5
6
use JDolba\SlimHttpSmokeTesting\RouteConfiguration\RouteConfigurationInterface;
7
use JDolba\SlimHttpSmokeTesting\RouteConfiguration\SlimRouteConfiguration;
8
use Slim\Route;
9
use Slim\Router;
10
11
class SlimRouterAdapter implements RouterAdapterInterface
12
{
13
    /**
14
     * @var \Slim\Router
15
     */
16
    private $router;
17
18
    public function __construct(Router $router)
19
    {
20
        $this->router = $router;
21
    }
22
23
    /**
24
     * @return \JDolba\SlimHttpSmokeTesting\RouteConfiguration\RouteConfigurationInterface[]
25
     */
26
    public function getRouteConfigurations(): array
27
    {
28
        $configurations = [];
29
        foreach ($this->router->getRoutes() as $route) {
30
            $routeConfiguration = new SlimRouteConfiguration($route);
31
            $route->setName($routeConfiguration->getRouteName());
32
            $configurations[] = $routeConfiguration;
33
        }
34
35
        return $configurations;
36
    }
37
38
    /**
39
     * @param \JDolba\SlimHttpSmokeTesting\RouteConfiguration\RouteConfigurationInterface $routeConfiguration
40
     * @param string[] $uriParams params passed to generate URI part; keys are name of params in URI
41
     * @param string[] $queryParams not mandatory query parts (to be used like ?foo=bar)
42
     * @return string
43
     */
44
    public function generateRelativePath(
45
        RouteConfigurationInterface $routeConfiguration,
46
        array $uriParams = [],
47
        array $queryParams = []
48
    ): string {
49
        return $this->router->relativePathFor(
50
            $routeConfiguration->getRouteName(),
51
            $uriParams,
52
            $queryParams
53
        );
54
    }
55
}
56