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.

RouteDefinition   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Test Coverage

Coverage 74.19%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 91
ccs 23
cts 31
cp 0.7419
rs 10
c 0
b 0
f 0
wmc 14

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequirements() 0 3 1
A getPathRegex() 0 3 1
A isAuth() 0 3 1
A getParams() 0 3 1
A addDefaults() 0 4 2
A getDefaults() 0 3 1
A getParam() 0 3 2
A getDefault() 0 3 2
A getName() 0 3 1
A setDefaults() 0 3 1
A __construct() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lib\Routing;
6
7
class RouteDefinition
8
{
9
    /**
10
     * @var string
11
     */
12
    private $name;
13
14
    /**
15
     * @var string
16
     */
17
    private $pathRegex;
18
    /**
19
     * @var array
20
     */
21
    private $requirements;
22
    /**
23
     * @var array
24
     */
25
    private $defaults = ['controller' => 'Default', 'action' => 'notFound'];
26
    /**
27
     * @var bool
28
     */
29
    private $auth;
30
    /**
31
     * @var array
32
     */
33
    private $params;
34
35
    /**
36
     * undocumented function.
37
     */
38 16
    public function __construct(string $name, string $pathRegex, array $requirements = [], array $defaults = [], bool $auth = false, array $params = [])
39
    {
40 16
        $this->name = $name;
41 16
        $this->pathRegex = $pathRegex;
42 16
        $this->requirements = $requirements;
43 16
        $this->defaults = array_merge($this->defaults, $defaults);
44 16
        $this->auth = $auth;
45 16
        $this->params = $params;
46 16
    }
47
48 2
    public function getName(): string
49
    {
50 2
        return $this->name;
51
    }
52
53 6
    public function getPathRegex(): string
54
    {
55 6
        return $this->pathRegex;
56
    }
57
58 6
    public function getRequirements(): array
59
    {
60 6
        return $this->requirements;
61
    }
62
63 1
    public function getDefaults(): array
64
    {
65 1
        return $this->defaults;
66
    }
67
68 1
    public function setDefaults(array $defaults = [])
69
    {
70 1
        $this->defaults = $defaults;
71 1
    }
72
73 2
    public function getDefault($name)
74
    {
75 2
        return isset($this->defaults[$name]) ? $this->defaults[$name] : false;
76
    }
77
78
    public function addDefaults(array $defaults)
79
    {
80
        foreach ($defaults as $name => $default) {
81
            $this->defaults[$name] = $default;
82
        }
83
    }
84
85 1
    public function isAuth(): bool
86
    {
87 1
        return $this->auth;
88
    }
89
90
    public function getParams(): array
91
    {
92
        return $this->params;
93
    }
94
95
    public function getParam($name)
96
    {
97
        return isset($this->params[$name]) ? $this->params[$name] : false;
98
    }
99
}
100