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.

RouteLoader::loadRoutes()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 0
dl 0
loc 17
ccs 12
cts 12
cp 1
crap 2
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lib\Routing;
6
7
use GuzzleHttp\Psr7\UriResolver;
8
use Symfony\Component\Yaml\Parser;
9
10
class RouteLoader
11
{
12
    /**
13
     * @var string
14
     */
15
    private $rootDir;
16
    /**
17
     * @var string
18
     */
19
    private $routeFile;
20
21
    /**
22
     * @var Parser
23
     */
24
    private $parser;
25
26 8
    public function __construct(string $path = null)
27
    {
28 8
        $path = $path ? ltrim($path, '/') : 'config/routes.yml';
29
30 8
        $this->rootDir = UriResolver::removeDotSegments(__DIR__.'/../../../');
31 8
        $this->routeFile = "{$this->rootDir}{$path}";
32 8
        $this->parser = new Parser();
33 8
    }
34
35 8
    public function loadRoutes()
36
    {
37 8
        $routes = new RouteCollection();
38 8
        $routesArr = $this->parser->parseFile($this->routeFile);
39
40 8
        foreach ($routesArr as $name => $row) {
41 8
            $path = $row['path'];
42 8
            $requirements = $row['requirements'] ?? [];
43 8
            $defaults = $row['defaults'] ?? [];
44 8
            $auth = $row['auth'] ?? false;
45 8
            $params = $row['params'] ?? [];
46
47 8
            $route = new RouteDefinition($name, $path, $requirements, $defaults, $auth, $params);
48 8
            $routes->add($name, $route);
49
        }
50
51 8
        return $routes;
52
    }
53
}
54