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 ( 2e753f...99a73b )
by Benjamin
03:04
created

RouteDefinition   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Test Coverage

Coverage 74.19%

Importance

Changes 0
Metric Value
dl 0
loc 93
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 __construct() 0 8 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
1
<?php
2
3
namespace Lib\Routing;
4
5
class RouteDefinition
6
{
7
    /**
8
     * @var string
9
     */
10
    private $name;
11
12
    /**
13
     * @var string
14
     */
15
    private $pathRegex;
16
    /**
17
     * @var array
18
     */
19
    private $requirements;
20
    /**
21
     * @var array
22
     */
23
    private $defaults = ['controller' => 'Default', 'action' => 'notFound'];
24
    /**
25
     * @var bool
26
     */
27
    private $auth;
28
    /**
29
     * @var array
30
     */
31
    private $params;
32
33
    /**
34
     * undocumented function
35
     *
36
     * @return void
37
     */
38 11
    public function __construct(string $name, string $pathRegex, array $requirements = [], array $defaults = [], bool $auth = false, array $params = [])
39
    {
40 11
        $this->name         = $name;
41 11
        $this->pathRegex    = $pathRegex;
42 11
        $this->requirements = $requirements;
43 11
        $this->defaults     = array_merge($this->defaults, $defaults);
44 11
        $this->auth         = $auth;
45 11
        $this->params       = $params;
46 11
    }
47
48 2
    public function getName(): string
49
    {
50 2
        return $this->name;
51
    }
52
53 5
    public function getPathRegex(): string
54
    {
55 5
        return $this->pathRegex;
56
    }
57
58 5
    public function getRequirements(): array
59
    {
60 5
        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