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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 42
ccs 0
cts 23
cp 0
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRouteConfigurations() 0 10 2
A generateRelativePath() 0 9 1
A __construct() 0 3 1
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