Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
326 lines (293 loc) · 6.7 KB

File metadata and controls

326 lines (293 loc) · 6.7 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<?php
/**
* This file is part of the Stack package.
*
* (c) Andrzej Kostrzewa <andkos11@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Stack\Routing;
/**
* A Route describes a route and its parameters.
*
* @author Andrzej Kostrzewa <andkos11@gmail.com>
*/
final class Route implements \Serializable
{
/**
* @var array
*/
private $accepts = [];
/**
* @var array
*/
private $allows = [];
/**
* @var array
*/
private $attributes = [];
/**
* @var array
*/
private $auth = [];
/**
* @var array
*/
private $defaults = [];
/**
* @var callable
*/
private $handler;
/**
* @var string
*/
private $host;
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $path;
/**
* @var bool
*/
private $isRoutable = true;
/**
* @var array
*/
private $requirements = [];
/**
* @var bool
*/
private $secure = false;
/**
* @var string
*/
private $wildcard;
/**
* Route constructor.
*
* @param string $name
* @param string $path
* @param mixed $handler
*/
public function __construct(
string $name,
string $path,
callable $handler = null
) {
$this->name = $name;
$this->path = $path;
$this->handler = $handler;
}
/**
* Create Route with optional parameters
*
* @param string $name
* @param string $path
* @param callable $handler
* @param array $defaults
* @param array $requirements
* @param string $host
* @param array $accepts
* @param array $allows
* @param array $attributes
* @param array $auth
* @param bool $secure
* @param string $wildcard
* @param bool $isRoutable
*
* @return Route
*/
public static function createWithOptional(
string $name,
string $path,
callable $handler = null,
array $defaults = [],
array $requirements = [],
string $host = '',
array $accepts = [],
array $allows = [],
array $attributes = [],
array $auth = [],
bool $secure = false,
string $wildcard = '',
bool $isRoutable = true
) {
$route = new Route($name, $path, $handler);
$route->defaults = $defaults;
$route->requirements = $requirements;
$route->host = $host;
$route->accepts = $accepts;
$route->allows = $allows;
$route->attributes = $attributes;
$route->auth = $auth;
$route->secure = $secure;
$route->wildcard = $wildcard;
$route->isRoutable = $isRoutable;
return $route;
}
/**
* Returns accepted headers of route.
*
* @return array
*/
public function accepts() : array
{
return $this->accepts;
}
/**
* Returns allows methods of route.
*
* @return array
*/
public function allows() : array
{
return $this->allows;
}
/**
* Returns the attributes of route.
*
* @return array
*/
public function attributes() : array
{
return $this->attributes;
}
/**
* Returns the authentication/authorization values.
*
* @return array
*/
public function auth() : array
{
return $this->auth;
}
/**
* Returns default attribute values.
*
* @return array
*/
public function defaults() : array
{
return $this->defaults;
}
/**
* Returns the handler of route.
*
* @return callable
*/
public function handler() : callable
{
return $this->handler;
}
/**
* Returns the host of route.
*
* @return string
*/
public function host() : string
{
return $this->host;
}
/**
* Return true if this route can be matched; if not, it
* can be used only to generate a path.
*
* @return bool
*/
public function isRoutable() : bool
{
return $this->isRoutable;
}
/**
* Returns the name of route.
*
* @return string
*/
public function name() : string
{
return $this->name;
}
/**
* Returns the pattern for the path.
*
* @return string
*/
public function path() : string
{
return $this->path;
}
/**
* Returns the requirements for the route.
*
* @return array
*/
public function requirements() : array
{
return $this->requirements;
}
/**
* Return true if this route respond on secure protocol.
*
* @return bool
*/
public function secure() : bool
{
return $this->secure;
}
/**
* Returns the wildcard name of route.
*
* @return string
*/
public function wildcard() : string
{
return $this->wildcard;
}
/**
* {@inheritdoc}
*/
public function serialize() : string
{
return serialize([
'name' => $this->name,
'path' => $this->path,
'host' => $this->host,
'defaults' => $this->defaults,
'requirements' => $this->requirements,
'accepts' => $this->accepts,
'allows' => $this->allows,
'attributes' => $this->attributes,
'auth' => $this->auth,
'secure' => $this->secure,
'handler' => $this->handler,
'wildcard' => $this->wildcard,
'isRoutable' => $this->isRoutable,
]);
}
/**
* {@inheritdoc}
*/
public function unserialize($serialized)
{
$data = unserialize($serialized);
$this->name = $data['name'];
$this->path = $data['path'];
$this->host = $data['host'];
$this->defaults = $data['defaults'];
$this->requirements = $data['requirements'];
$this->accepts = $data['accepts'];
$this->allows = $data['allows'];
$this->attributes = $data['attributes'];
$this->auth = $data['auth'];
$this->secure = $data['secure'];
$this->handler = $data['handler'];
$this->wildcard = $data['wildcard'];
$this->isRoutable = $data['isRoutable'];
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.