Total Complexity | 14 |
Total Lines | 91 |
Duplicated Lines | 0 % |
Coverage | 74.19% |
Changes | 0 |
1 | <?php |
||
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 |
|
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 |
|
88 | } |
||
89 | |||
90 | public function getParams(): array |
||
93 | } |
||
94 | |||
95 | public function getParam($name) |
||
98 | } |
||
99 | } |
||
100 |