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 ( 84bb15...86ae46 )
by Benjamin
05:01
created

RouteLoader::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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