1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kambo\Router\Route; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Parsed route from matcher class. |
7
|
|
|
* Class is implemented as a proxy for existing Route object. |
8
|
|
|
* |
9
|
|
|
* @package Kambo\Router\Route |
10
|
|
|
* @author Bohuslav Simek <[email protected]> |
11
|
|
|
* @license MIT |
12
|
|
|
*/ |
13
|
|
|
class ParsedRoute |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Instance of original route |
17
|
|
|
* |
18
|
|
|
* @var \Kambo\Router\Route |
19
|
|
|
*/ |
20
|
|
|
private $route; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Route placeholders from route. |
24
|
|
|
* |
25
|
|
|
* @var array |
26
|
|
|
*/ |
27
|
|
|
private $placeholders; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Route parameters from request |
31
|
|
|
* |
32
|
|
|
* @var array |
33
|
|
|
*/ |
34
|
|
|
private $parameters; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* ParsedRoute constructor |
38
|
|
|
* |
39
|
|
|
* @param \Kambo\Router\Route $route |
40
|
|
|
*/ |
41
|
18 |
|
public function __construct(Route $route) |
42
|
|
|
{ |
43
|
18 |
|
$this->route = $route; |
|
|
|
|
44
|
18 |
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Get route method |
48
|
|
|
* |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
16 |
|
public function getMethod() |
52
|
|
|
{ |
53
|
16 |
|
return $this->route->getMethod(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get handler |
58
|
|
|
* |
59
|
|
|
* @return mixed |
60
|
|
|
*/ |
61
|
16 |
|
public function getHandler() |
62
|
|
|
{ |
63
|
16 |
|
return $this->route->getHandler(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Sets placeholders extracted from route. |
68
|
|
|
* |
69
|
|
|
* @param mixed $parameters |
|
|
|
|
70
|
|
|
* |
71
|
|
|
* @return self for fluent interface |
72
|
|
|
*/ |
73
|
18 |
|
public function setPlaceholders($placeholders) |
74
|
|
|
{ |
75
|
18 |
|
$this->placeholders = $placeholders; |
76
|
|
|
|
77
|
18 |
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Get placeholders extracted from route. |
82
|
|
|
* |
83
|
|
|
* @return array |
84
|
|
|
*/ |
85
|
15 |
|
public function getPlaceholders() |
86
|
|
|
{ |
87
|
15 |
|
return $this->placeholders; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Sets parameters for route from request. |
92
|
|
|
* |
93
|
|
|
* @param mixed $parameters |
94
|
|
|
* |
95
|
|
|
* @return self for fluent interface |
96
|
|
|
*/ |
97
|
16 |
|
public function setParameters($parameters) |
98
|
|
|
{ |
99
|
16 |
|
$this->parameters = $parameters; |
|
|
|
|
100
|
|
|
|
101
|
16 |
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Get parameters of route from request. |
106
|
|
|
* |
107
|
|
|
* @return array |
108
|
|
|
*/ |
109
|
15 |
|
public function getParameters() |
110
|
|
|
{ |
111
|
15 |
|
return $this->parameters; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..