Total Complexity | 13 |
Total Lines | 88 |
Duplicated Lines | 0 % |
Coverage | 50% |
Changes | 0 |
1 | <?php |
||
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 | 4 | public function __construct(string $name, string $pathRegex, array $requirements = [], array $defaults = [], bool $auth = false, array $params = []) |
|
39 | { |
||
40 | 4 | $this->name = $name; |
|
41 | 4 | $this->pathRegex = $pathRegex; |
|
42 | 4 | $this->requirements = $requirements; |
|
43 | 4 | $this->defaults = array_merge($this->defaults, $defaults); |
|
44 | 4 | $this->auth = $auth; |
|
45 | 4 | $this->params = $params; |
|
46 | 4 | } |
|
47 | |||
48 | public function getName(): string |
||
49 | { |
||
50 | return $this->name; |
||
51 | } |
||
52 | |||
53 | 4 | public function getPathRegex(): string |
|
54 | { |
||
55 | 4 | return $this->pathRegex; |
|
56 | } |
||
57 | |||
58 | 4 | public function getRequirements(): array |
|
59 | { |
||
60 | 4 | return $this->requirements; |
|
61 | } |
||
62 | |||
63 | public function getDefaults(): array |
||
64 | { |
||
65 | return $this->defaults; |
||
66 | } |
||
67 | |||
68 | 2 | public function getDefault($name) |
|
69 | { |
||
70 | 2 | return isset($this->defaults[$name]) ? $this->defaults[$name] : false; |
|
71 | } |
||
72 | |||
73 | public function addDefaults(array $defaults) |
||
74 | { |
||
75 | foreach ($defaults as $name => $default) { |
||
76 | $this->defaults[$name] = $default; |
||
77 | } |
||
78 | } |
||
79 | |||
80 | public function isAuth(): bool |
||
81 | { |
||
82 | return $this->auth; |
||
83 | } |
||
84 | |||
85 | public function getParams(): array |
||
88 | } |
||
89 | |||
90 | public function getParam($name) |
||
91 | { |
||
92 | return isset($this->params[$name]) ? $this->params[$name] : false; |
||
93 | } |
||
94 | } |
||
95 |