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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
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
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