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

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 42
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A loadRoutes() 0 17 2
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