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 ( 17370b...216ab3 )
by Benjamin
02:35
created

RouteLoader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 43
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A loadRoutes() 0 17 2
1
<?php
2
3
namespace App\Lib\Routing;
4
5
use Symfony\Component\Yaml\Parser;
6
7
class RouteLoader
8
{
9
    /**
10
     * @var string
11
     */
12
    private $rootDir;
13
    /**
14
     * @var string
15
     */
16
    private $routeFile;
17
18
    /**
19
     * @var Parser
20
     */
21
    private $parser;
22
23 4
    public function __construct(string $path = null)
24
    {
25 4
        $path = $path ?? '/config/routes.yml';
26 4
        list($scriptName) = get_included_files();
27
28 4
        $this->rootDir   = dirname(realpath($scriptName));
29 4
        $this->routeFile = "{$this->rootDir}{$path}";
30 4
        $this->parser    = new Parser();
31 4
    }
32
33 4
    public function loadRoutes()
34
    {
35 4
        $routes    = new RouteCollection();
36 4
        $routesArr = $this->parser->parseFile($this->routeFile);
37
38 4
        foreach ($routesArr as $name => $row) {
39 4
            $path         = $row['path'];
40 4
            $requirements = $row['requirements'] ?? [];
41 4
            $defaults     = $row['defaults'] ?? [];
42 4
            $auth         = $row['auth'] ?? false;
43 4
            $params       = $row['params'] ?? [];
44
45 4
            $route = new RouteDefinition($name, $path, $requirements, $defaults, $auth, $params);
46 4
            $routes->add($name, $route);
47
        }
48
49 4
        return $routes;
50
    }
51
}
52