1 | <?php |
||
12 | class Route |
||
13 | { |
||
14 | use RouteReflection; |
||
15 | |||
16 | /** @var string */ |
||
17 | protected $url; |
||
18 | |||
19 | /** @var */ |
||
20 | protected $callable; |
||
21 | |||
22 | /** @var */ |
||
23 | protected $name; |
||
24 | |||
25 | /** @var array */ |
||
26 | private static $parameters = []; |
||
27 | |||
28 | /** @var array */ |
||
29 | private static $attributes = []; |
||
30 | |||
31 | /** @var Request */ |
||
32 | protected $request; |
||
33 | |||
34 | /** @var Response */ |
||
35 | protected $response; |
||
36 | |||
37 | /** @var */ |
||
38 | protected $running; |
||
39 | |||
40 | /** |
||
41 | * Route constructor. |
||
42 | * @param $url |
||
43 | * @param $callable |
||
44 | * @param null $name |
||
45 | */ |
||
46 | public function __construct($url, $callable, $name = null) |
||
54 | |||
55 | /** |
||
56 | * Check the path, if there are parameters to create attributes for the scope of the request |
||
57 | * |
||
58 | * @param $url |
||
59 | * @return bool |
||
60 | */ |
||
61 | public function extractParameters($url) |
||
72 | |||
73 | /** |
||
74 | * ... |
||
75 | * |
||
76 | * @param $match |
||
77 | * @return string |
||
78 | */ |
||
79 | private function attributesMatch($match) { |
||
85 | |||
86 | /** |
||
87 | * Get url. |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | public function getUrl(): string |
||
95 | |||
96 | /** |
||
97 | * Get name route |
||
98 | * |
||
99 | * @return null|string |
||
100 | */ |
||
101 | public function getName() |
||
105 | |||
106 | /** |
||
107 | * Get callback. |
||
108 | * |
||
109 | * @return mixed |
||
110 | */ |
||
111 | public function getCallable() |
||
115 | |||
116 | /** |
||
117 | * Get params. |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | public static function getParameters(): array |
||
125 | |||
126 | /** |
||
127 | * Get properties on route |
||
128 | * |
||
129 | * @return array |
||
130 | */ |
||
131 | public function getRoute() |
||
140 | |||
141 | /** |
||
142 | * Get request |
||
143 | * |
||
144 | * @return Request |
||
145 | */ |
||
146 | public function getRequest(): Request |
||
150 | |||
151 | /** |
||
152 | * Get reponse |
||
153 | * |
||
154 | * @return Response |
||
155 | */ |
||
156 | public function getResponse(): Response |
||
160 | |||
161 | /** |
||
162 | * Executing route |
||
163 | * |
||
164 | * @param array $parameters |
||
165 | * @return mixed |
||
166 | */ |
||
167 | public function requestUrlCall($parameters = []) |
||
176 | |||
177 | /** |
||
178 | * Exporta para o controlador uma coleção de dados; |
||
179 | * |
||
180 | * @param string $attribute |
||
181 | * @param string $regex |
||
182 | * @return $this |
||
183 | */ |
||
184 | public function with(string $attribute, string $regex) |
||
189 | |||
190 | /** |
||
191 | * Check the type of request and define which treatment it should receive |
||
192 | * |
||
193 | * @return mixed |
||
194 | */ |
||
195 | public function run() |
||
202 | } |