1 | <?php |
||
7 | class Route |
||
8 | { |
||
9 | /** |
||
10 | * The URI pattern the route responds to. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $uri; |
||
15 | |||
16 | /** |
||
17 | * The HTTP methods the route responds to. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $methods; |
||
22 | |||
23 | /** |
||
24 | * The route action array. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $action; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $parameters = []; |
||
34 | |||
35 | /** |
||
36 | * Create a new Route instance. |
||
37 | * |
||
38 | * @param string|array $methods |
||
39 | * @param string $uri |
||
40 | * @param Closure|array $action |
||
41 | * |
||
42 | * @throws UnexpectedValueException |
||
43 | */ |
||
44 | 29 | public function __construct($methods, $uri, $action) |
|
55 | |||
56 | /** |
||
57 | * @param array $parameters |
||
58 | */ |
||
59 | 5 | public function bind(array $parameters = []) |
|
63 | |||
64 | /** |
||
65 | * Parse the route action into a standard array. |
||
66 | * |
||
67 | * @param callable|array $action |
||
68 | * |
||
69 | * @throws UnexpectedValueException |
||
70 | * @return array |
||
71 | */ |
||
72 | 29 | protected function parseAction($action) |
|
88 | |||
89 | /** |
||
90 | * @return array |
||
91 | */ |
||
92 | 7 | public function methods() : array |
|
96 | |||
97 | /** |
||
98 | * @return string |
||
99 | */ |
||
100 | 8 | public function uri() : string |
|
104 | |||
105 | /** |
||
106 | * @return array |
||
107 | */ |
||
108 | 10 | public function action() : array |
|
112 | |||
113 | /** |
||
114 | * @return array |
||
115 | */ |
||
116 | 3 | public function parameters() : array |
|
120 | |||
121 | /** |
||
122 | * @param $uri |
||
123 | */ |
||
124 | 29 | public function setUri(string $uri) |
|
128 | |||
129 | /** |
||
130 | * @param string $name |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | 1 | public function hasParameter(string $name) |
|
138 | |||
139 | /** |
||
140 | * @param string $name |
||
141 | * |
||
142 | * @return mixed |
||
143 | */ |
||
144 | 1 | public function parameter(string $name) |
|
148 | } |
||
149 |