@@ -46,7 +46,7 @@ |
||
46 | 46 | |
47 | 47 | // Finally, we will set the application's environment based on the configuration |
48 | 48 | // values that were loaded. |
49 | - $app->detectEnvironment(function () use ($config) { |
|
49 | + $app->detectEnvironment(function() use ($config) { |
|
50 | 50 | return $config->get('app.env', 'production'); |
51 | 51 | }); |
52 | 52 |
@@ -32,26 +32,26 @@ |
||
32 | 32 | */ |
33 | 33 | class BootConfiguration |
34 | 34 | { |
35 | - /** |
|
36 | - * Bootstrap the given application. |
|
37 | - * |
|
38 | - * @param \Syscodes\Components\Contracts\Core\Application $app |
|
39 | - * |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function bootstrap(Application $app) |
|
43 | - { |
|
44 | - $app->instance('config', $config = new Configure); |
|
35 | + /** |
|
36 | + * Bootstrap the given application. |
|
37 | + * |
|
38 | + * @param \Syscodes\Components\Contracts\Core\Application $app |
|
39 | + * |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function bootstrap(Application $app) |
|
43 | + { |
|
44 | + $app->instance('config', $config = new Configure); |
|
45 | 45 | |
46 | - // Finally, we will set the application's environment based on the configuration |
|
46 | + // Finally, we will set the application's environment based on the configuration |
|
47 | 47 | // values that were loaded. |
48 | - $app->detectEnvironment(function () use ($config) { |
|
49 | - return $config->get('app.env', 'production'); |
|
50 | - }); |
|
48 | + $app->detectEnvironment(function () use ($config) { |
|
49 | + return $config->get('app.env', 'production'); |
|
50 | + }); |
|
51 | 51 | |
52 | - // Set a default timezone if one is defined |
|
53 | - date_default_timezone_set($config->get('app.timezone', 'UTC')); |
|
52 | + // Set a default timezone if one is defined |
|
53 | + date_default_timezone_set($config->get('app.timezone', 'UTC')); |
|
54 | 54 | |
55 | - mb_internal_encoding('UTF-8'); |
|
56 | - } |
|
55 | + mb_internal_encoding('UTF-8'); |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | \ No newline at end of file |
@@ -39,7 +39,7 @@ |
||
39 | 39 | */ |
40 | 40 | public function register() |
41 | 41 | { |
42 | - $this->app->booted(function () |
|
42 | + $this->app->booted(function() |
|
43 | 43 | { |
44 | 44 | $this->app['router']->getRoutes()->refreshNameLookups(); |
45 | 45 | $this->app['router']->getRoutes()->refreshActionLookups(); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | protected static function usesAction($uri) |
78 | 78 | { |
79 | - return ['uses' => function () use ($uri) { |
|
79 | + return ['uses' => function() use ($uri) { |
|
80 | 80 | throw new LogicException(__('route.hasNoAction', ['uri' => $uri])); |
81 | 81 | }]; |
82 | 82 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected static function findClosureAction(array $action) |
92 | 92 | { |
93 | - return Arr::first($action, function ($value, $key) { |
|
93 | + return Arr::first($action, function($value, $key) { |
|
94 | 94 | return is_callable($value) && is_numeric($key); |
95 | 95 | }); |
96 | 96 | } |
@@ -258,7 +258,7 @@ |
||
258 | 258 | */ |
259 | 259 | public function getSegments() |
260 | 260 | { |
261 | - return array_values(array_filter($this->segments, function ($value) { |
|
261 | + return array_values(array_filter($this->segments, function($value) { |
|
262 | 262 | return $value != ''; |
263 | 263 | })); |
264 | 264 | } |
@@ -32,514 +32,514 @@ |
||
32 | 32 | */ |
33 | 33 | class URI |
34 | 34 | { |
35 | - /** |
|
36 | - * Returns default schemes/ports. |
|
37 | - * |
|
38 | - * @var array $defaultPorts |
|
39 | - */ |
|
40 | - protected $defaultPorts = [ |
|
41 | - 'http' => 80, |
|
42 | - 'https' => 443, |
|
43 | - 'ftp' => 21, |
|
44 | - 'sftp' => 22 |
|
45 | - ]; |
|
46 | - |
|
47 | - /** |
|
48 | - * The name of any fragment. |
|
49 | - * |
|
50 | - * @var string $fragment |
|
51 | - */ |
|
52 | - protected $fragment = ''; |
|
53 | - |
|
54 | - /** |
|
55 | - * The URI Host. |
|
56 | - * |
|
57 | - * @var string $host |
|
58 | - */ |
|
59 | - protected $host; |
|
35 | + /** |
|
36 | + * Returns default schemes/ports. |
|
37 | + * |
|
38 | + * @var array $defaultPorts |
|
39 | + */ |
|
40 | + protected $defaultPorts = [ |
|
41 | + 'http' => 80, |
|
42 | + 'https' => 443, |
|
43 | + 'ftp' => 21, |
|
44 | + 'sftp' => 22 |
|
45 | + ]; |
|
46 | + |
|
47 | + /** |
|
48 | + * The name of any fragment. |
|
49 | + * |
|
50 | + * @var string $fragment |
|
51 | + */ |
|
52 | + protected $fragment = ''; |
|
53 | + |
|
54 | + /** |
|
55 | + * The URI Host. |
|
56 | + * |
|
57 | + * @var string $host |
|
58 | + */ |
|
59 | + protected $host; |
|
60 | 60 | |
61 | - /** |
|
62 | - * The URI User Password. |
|
63 | - * |
|
64 | - * @var string $password |
|
65 | - */ |
|
66 | - protected $password; |
|
67 | - |
|
68 | - /** |
|
69 | - * The URI path. |
|
70 | - * |
|
71 | - * @var string $path |
|
72 | - */ |
|
73 | - protected $path; |
|
74 | - |
|
75 | - /** |
|
76 | - * The URI Port. |
|
77 | - * |
|
78 | - * @var int $port |
|
79 | - */ |
|
80 | - protected $port; |
|
81 | - |
|
82 | - /** |
|
83 | - * The query string. |
|
84 | - * |
|
85 | - * @var string $query |
|
86 | - */ |
|
87 | - protected $query; |
|
88 | - |
|
89 | - /** |
|
90 | - * The URI Scheme. |
|
91 | - * |
|
92 | - * @var string $scheme |
|
93 | - */ |
|
94 | - protected $scheme = 'http'; |
|
95 | - |
|
96 | - /** |
|
97 | - * The URI segments. |
|
98 | - * |
|
99 | - * @var array $segments |
|
100 | - */ |
|
101 | - protected $segments = []; |
|
102 | - |
|
103 | - /** |
|
104 | - * Whether passwords should be shown in userInfo/authority calls. |
|
105 | - * |
|
106 | - * @var boolean $showPassword |
|
107 | - */ |
|
108 | - protected $showPassword = false; |
|
61 | + /** |
|
62 | + * The URI User Password. |
|
63 | + * |
|
64 | + * @var string $password |
|
65 | + */ |
|
66 | + protected $password; |
|
67 | + |
|
68 | + /** |
|
69 | + * The URI path. |
|
70 | + * |
|
71 | + * @var string $path |
|
72 | + */ |
|
73 | + protected $path; |
|
74 | + |
|
75 | + /** |
|
76 | + * The URI Port. |
|
77 | + * |
|
78 | + * @var int $port |
|
79 | + */ |
|
80 | + protected $port; |
|
81 | + |
|
82 | + /** |
|
83 | + * The query string. |
|
84 | + * |
|
85 | + * @var string $query |
|
86 | + */ |
|
87 | + protected $query; |
|
88 | + |
|
89 | + /** |
|
90 | + * The URI Scheme. |
|
91 | + * |
|
92 | + * @var string $scheme |
|
93 | + */ |
|
94 | + protected $scheme = 'http'; |
|
95 | + |
|
96 | + /** |
|
97 | + * The URI segments. |
|
98 | + * |
|
99 | + * @var array $segments |
|
100 | + */ |
|
101 | + protected $segments = []; |
|
102 | + |
|
103 | + /** |
|
104 | + * Whether passwords should be shown in userInfo/authority calls. |
|
105 | + * |
|
106 | + * @var boolean $showPassword |
|
107 | + */ |
|
108 | + protected $showPassword = false; |
|
109 | 109 | |
110 | - /** |
|
111 | - * The URI User Info. |
|
112 | - * |
|
113 | - * @var string $user |
|
114 | - */ |
|
115 | - protected $user; |
|
116 | - |
|
117 | - /** |
|
118 | - * Constructor. The URI class instance. |
|
119 | - * |
|
120 | - * @param string|null $uri |
|
121 | - * |
|
122 | - * @return void |
|
123 | - * |
|
124 | - * @throws \Syscodes\Components\Http\Exceptions\HttpURIException |
|
125 | - */ |
|
126 | - public function __construct(string $uri = null) |
|
127 | - { |
|
128 | - if ( ! is_null($uri)) { |
|
129 | - $this->setUri($uri); |
|
130 | - } |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Sets and overwrites any current URI information. |
|
135 | - * |
|
136 | - * @param string|null $uri |
|
137 | - * |
|
138 | - * @return mixed |
|
139 | - * |
|
140 | - * @throws \Syscodes\Components\Http\Exceptions\HttpURIException |
|
141 | - */ |
|
142 | - public function setUri(string $uri = null) |
|
143 | - { |
|
144 | - if ( ! is_null($uri)) { |
|
145 | - $parts = parse_url($uri); |
|
146 | - |
|
147 | - if ($parts === false) { |
|
148 | - throw HttpURIException::UnableToParseURI($uri); |
|
149 | - } |
|
150 | - |
|
151 | - $this->applyParts($parts); |
|
152 | - } |
|
153 | - |
|
154 | - return $this; |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Returns the full URI string. |
|
159 | - * |
|
160 | - * @return string The URI string |
|
161 | - */ |
|
162 | - public function get(): string |
|
163 | - { |
|
164 | - return '/'.ltrim($this->path, '/'); |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * Sets of URI string. |
|
169 | - * |
|
170 | - * @param string $uri |
|
171 | - * |
|
172 | - * @return self |
|
173 | - */ |
|
174 | - public function set($uri): self |
|
175 | - { |
|
176 | - $this->path = $uri; |
|
177 | - |
|
178 | - return $this; |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Retrieve the path component of the URI. The path can either be empty or absolute |
|
183 | - * (starting with a slash) or rootless (not starting with a slash). |
|
184 | - * |
|
185 | - * @return string |
|
186 | - */ |
|
187 | - public function getPath(): string |
|
188 | - { |
|
189 | - return (is_null($this->path) ? '' : $this->path); |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Sets the path portion of the URI. |
|
194 | - * |
|
195 | - * @param string $path |
|
196 | - * |
|
197 | - * @return self |
|
198 | - */ |
|
199 | - public function setPath(string $path): self |
|
200 | - { |
|
201 | - $this->path = $this->filterPath($path); |
|
202 | - |
|
203 | - $tempPath = trim($this->path, '/'); |
|
204 | - |
|
205 | - $this->filterSegments($tempPath); |
|
206 | - |
|
207 | - return $this; |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * Encodes any dangerous characters. |
|
212 | - * |
|
213 | - * @param string|null $path |
|
214 | - * |
|
215 | - * @return string |
|
216 | - */ |
|
217 | - protected function filterPath(string $path = null): string |
|
218 | - { |
|
219 | - $path = urldecode($path); |
|
220 | - |
|
221 | - return $path; |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * Filter the segments of path. |
|
226 | - * |
|
227 | - * @param string $uri |
|
228 | - * |
|
229 | - * @return string[] |
|
230 | - */ |
|
231 | - protected function filterSegments($uri) |
|
232 | - { |
|
233 | - $this->segments = ($uri === '') ? [] : explode('/', $uri); |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Get the specified URI segment, return default if it doesn't exist. |
|
238 | - * Segment index is 1 based, not 0 based. |
|
239 | - * |
|
240 | - * @param int $index The 1-based segment index |
|
241 | - * @param mixed $default The default value |
|
242 | - * |
|
243 | - * @return mixed |
|
244 | - */ |
|
245 | - public function getSegment(int $index, $default = null) |
|
246 | - { |
|
247 | - return Arr::get($this->getSegments(), $index - 1, $default); |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Returns the segments of the path as an array. |
|
252 | - * |
|
253 | - * @return array The URI segments |
|
254 | - */ |
|
255 | - public function getSegments() |
|
256 | - { |
|
257 | - return array_values(array_filter($this->segments, function ($value) { |
|
258 | - return $value != ''; |
|
259 | - })); |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * Returns the total number of segment. |
|
264 | - * |
|
265 | - * @return int |
|
266 | - */ |
|
267 | - public function getTotalSegments(): int |
|
268 | - { |
|
269 | - return count($this->getSegments()); |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * Retrieve the scheme component of the URI. |
|
274 | - * |
|
275 | - * @return string |
|
276 | - */ |
|
277 | - public function getScheme(): string |
|
278 | - { |
|
279 | - return $this->scheme; |
|
280 | - } |
|
281 | - |
|
282 | - /** |
|
283 | - * Sets the scheme for this URI. |
|
284 | - * |
|
285 | - * @param string $str |
|
286 | - * |
|
287 | - * @return string |
|
288 | - */ |
|
289 | - public function setScheme(string $str): string |
|
290 | - { |
|
291 | - $str = preg_replace('~:(//)?$~', '', strtolower($str)); |
|
292 | - |
|
293 | - $this->scheme = $str; |
|
294 | - |
|
295 | - return $this->scheme; |
|
296 | - } |
|
297 | - |
|
298 | - /** |
|
299 | - * Retrieve the user component of the URI. |
|
300 | - * |
|
301 | - * @return string|null |
|
302 | - */ |
|
303 | - public function getUserInfo() |
|
304 | - { |
|
305 | - $user = $this->user; |
|
306 | - $pass = $this->password; |
|
307 | - |
|
308 | - if ($this->showPassword === true && ! empty($pass)) { |
|
309 | - $user .= ":$pass"; |
|
310 | - } |
|
311 | - |
|
312 | - return $user; |
|
313 | - } |
|
314 | - |
|
315 | - /** |
|
316 | - * Sets the user portion of the URI. |
|
317 | - * |
|
318 | - * @param string $user |
|
319 | - * |
|
320 | - * @return string|null |
|
321 | - */ |
|
322 | - public function setUser($user): string |
|
323 | - { |
|
324 | - $this->user = trim($user); |
|
325 | - |
|
326 | - return $this->user; |
|
327 | - } |
|
328 | - |
|
329 | - /** |
|
330 | - * Sets the password portion of the URI. |
|
331 | - * |
|
332 | - * @param string $password |
|
333 | - * |
|
334 | - * @return string|null |
|
335 | - */ |
|
336 | - public function setPassword($password): string |
|
337 | - { |
|
338 | - $this->password = trim($password); |
|
339 | - |
|
340 | - return $this->password; |
|
341 | - } |
|
342 | - |
|
343 | - /** |
|
344 | - * Temporarily sets the URI to show a password in userInfo. |
|
345 | - * |
|
346 | - * @param boolean $option |
|
347 | - * |
|
348 | - * @return self |
|
349 | - */ |
|
350 | - public function showPassword(bool $option = true): self |
|
351 | - { |
|
352 | - $this->showPassword = $option; |
|
353 | - |
|
354 | - return $this; |
|
355 | - } |
|
356 | - |
|
357 | - /** |
|
358 | - * Retrieve the authority component of the URI. |
|
359 | - * |
|
360 | - * @param boolean $ignore |
|
361 | - * |
|
362 | - * @return string |
|
363 | - */ |
|
364 | - public function getAuthority(bool $ignore = false): string |
|
365 | - { |
|
366 | - if (empty($this->host)) { |
|
367 | - return ''; |
|
368 | - } |
|
369 | - |
|
370 | - $authority = $this->host; |
|
371 | - |
|
372 | - if ( ! empty($this->getUserInfo())) { |
|
373 | - $authority = $this->getUserInfo().'@'.$authority; |
|
374 | - } |
|
375 | - |
|
376 | - if ( ! empty($this->port) && ! $ignore) { |
|
377 | - if ($this->port !== $this->defaultPorts[$this->scheme]) { |
|
378 | - $authority .= ":$this->port"; |
|
379 | - } |
|
380 | - } |
|
381 | - |
|
382 | - $this->showPassword = false; |
|
383 | - |
|
384 | - return $authority; |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * Parses the given string an saves the appropriate authority pieces. |
|
389 | - * |
|
390 | - * @param string $str |
|
391 | - * |
|
392 | - * @return self |
|
393 | - */ |
|
394 | - public function setAuthority(string $str): self |
|
395 | - { |
|
396 | - $parts = parse_url($str); |
|
397 | - |
|
398 | - if (empty($parts['host']) && ! empty($parts['path'])) { |
|
399 | - $parts['host'] = $parts['path']; |
|
400 | - unset($parts['path']); |
|
401 | - } |
|
402 | - |
|
403 | - $this->applyParts($parts); |
|
404 | - |
|
405 | - return $this; |
|
406 | - } |
|
407 | - |
|
408 | - /** |
|
409 | - * Retrieve the host component of the URI. |
|
410 | - * |
|
411 | - * @return string |
|
412 | - */ |
|
413 | - public function getHost(): string |
|
414 | - { |
|
415 | - return $this->host; |
|
416 | - } |
|
417 | - |
|
418 | - /** |
|
419 | - * Sets the host name to use. |
|
420 | - * |
|
421 | - * @param string $str |
|
422 | - * |
|
423 | - * @return string |
|
424 | - */ |
|
425 | - public function setHost(string $str): string |
|
426 | - { |
|
427 | - $this->host = trim($str); |
|
428 | - |
|
429 | - return $this->host; |
|
430 | - } |
|
431 | - |
|
432 | - /** |
|
433 | - * Retrieve the port component of the URI. |
|
434 | - * |
|
435 | - * @return int|null |
|
436 | - */ |
|
437 | - public function getPort() |
|
438 | - { |
|
439 | - return $this->port; |
|
440 | - } |
|
441 | - |
|
442 | - /** |
|
443 | - * Sets the port portion of the URI. |
|
444 | - * |
|
445 | - * @param int|null $port |
|
446 | - * |
|
447 | - * @return string |
|
448 | - */ |
|
449 | - public function setPort(int $port = null): string |
|
450 | - { |
|
451 | - if (is_null($port)) { |
|
452 | - return $this; |
|
453 | - } |
|
454 | - |
|
455 | - if ($port <= 0 || $port > 65355) { |
|
456 | - throw HttpURIException::invalidPort($port); |
|
457 | - } |
|
458 | - |
|
459 | - $this->port = $port; |
|
460 | - |
|
461 | - return $this->port; |
|
462 | - } |
|
463 | - |
|
464 | - /** |
|
465 | - * Retrieve a URI fragment. |
|
466 | - * |
|
467 | - * @return string |
|
468 | - */ |
|
469 | - public function getFragment(): string |
|
470 | - { |
|
471 | - return is_null($this->fragment) ? '' : $this->fragment; |
|
472 | - } |
|
473 | - |
|
474 | - /** |
|
475 | - * Sets the fragment portion of the URI. |
|
476 | - * |
|
477 | - * @param string $str |
|
478 | - * |
|
479 | - * @return string |
|
480 | - */ |
|
481 | - public function setFragment(string $str): string |
|
482 | - { |
|
483 | - $this->fragment = trim($str, '# '); |
|
484 | - |
|
485 | - return $this->fragment; |
|
486 | - } |
|
487 | - |
|
488 | - /** |
|
489 | - * Saves our parts from a parse_url call. |
|
490 | - * |
|
491 | - * @param array $parts |
|
492 | - * |
|
493 | - * @return mixed |
|
494 | - */ |
|
495 | - public function applyParts(array $paths) |
|
496 | - { |
|
497 | - if (isset($parts['scheme'])) { |
|
498 | - $this->SetScheme(rtrim($parts['scheme'], ':/')); |
|
499 | - } else { |
|
500 | - $this->setScheme('http'); |
|
501 | - } |
|
502 | - |
|
503 | - if ( ! empty($parts['host'])) { |
|
504 | - $this->host = $parts['host']; |
|
505 | - } |
|
506 | - |
|
507 | - if (isset($parts['port'])) { |
|
508 | - if ( ! is_null($parts['port'])) { |
|
509 | - $this->port = $parts['port']; |
|
510 | - } |
|
511 | - } |
|
512 | - |
|
513 | - if ( ! empty($parts['user'])) { |
|
514 | - $this->user = $parts['user']; |
|
515 | - } |
|
516 | - |
|
517 | - if ( ! empty($parts['pass'])) { |
|
518 | - $this->password = $parts['pass']; |
|
519 | - } |
|
520 | - |
|
521 | - if ( ! empty($parts['path'])) { |
|
522 | - $this->path = $this->filterPath($parts['path']); |
|
523 | - } |
|
524 | - |
|
525 | - if ( ! empty($parts['fragment'])) { |
|
526 | - $this->fragment = $parts['fragment']; |
|
527 | - } |
|
528 | - |
|
529 | - if ( ! empty($parts['path'])) { |
|
530 | - $this->segments = explode('/', $parts['path'], '/'); |
|
531 | - } |
|
532 | - } |
|
533 | - |
|
534 | - /** |
|
535 | - * Magic method. |
|
536 | - * |
|
537 | - * Returns the URI string. |
|
538 | - * |
|
539 | - * @return string |
|
540 | - */ |
|
541 | - public function __toString() |
|
542 | - { |
|
543 | - return (string) $this->getPath(); |
|
544 | - } |
|
110 | + /** |
|
111 | + * The URI User Info. |
|
112 | + * |
|
113 | + * @var string $user |
|
114 | + */ |
|
115 | + protected $user; |
|
116 | + |
|
117 | + /** |
|
118 | + * Constructor. The URI class instance. |
|
119 | + * |
|
120 | + * @param string|null $uri |
|
121 | + * |
|
122 | + * @return void |
|
123 | + * |
|
124 | + * @throws \Syscodes\Components\Http\Exceptions\HttpURIException |
|
125 | + */ |
|
126 | + public function __construct(string $uri = null) |
|
127 | + { |
|
128 | + if ( ! is_null($uri)) { |
|
129 | + $this->setUri($uri); |
|
130 | + } |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Sets and overwrites any current URI information. |
|
135 | + * |
|
136 | + * @param string|null $uri |
|
137 | + * |
|
138 | + * @return mixed |
|
139 | + * |
|
140 | + * @throws \Syscodes\Components\Http\Exceptions\HttpURIException |
|
141 | + */ |
|
142 | + public function setUri(string $uri = null) |
|
143 | + { |
|
144 | + if ( ! is_null($uri)) { |
|
145 | + $parts = parse_url($uri); |
|
146 | + |
|
147 | + if ($parts === false) { |
|
148 | + throw HttpURIException::UnableToParseURI($uri); |
|
149 | + } |
|
150 | + |
|
151 | + $this->applyParts($parts); |
|
152 | + } |
|
153 | + |
|
154 | + return $this; |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * Returns the full URI string. |
|
159 | + * |
|
160 | + * @return string The URI string |
|
161 | + */ |
|
162 | + public function get(): string |
|
163 | + { |
|
164 | + return '/'.ltrim($this->path, '/'); |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * Sets of URI string. |
|
169 | + * |
|
170 | + * @param string $uri |
|
171 | + * |
|
172 | + * @return self |
|
173 | + */ |
|
174 | + public function set($uri): self |
|
175 | + { |
|
176 | + $this->path = $uri; |
|
177 | + |
|
178 | + return $this; |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * Retrieve the path component of the URI. The path can either be empty or absolute |
|
183 | + * (starting with a slash) or rootless (not starting with a slash). |
|
184 | + * |
|
185 | + * @return string |
|
186 | + */ |
|
187 | + public function getPath(): string |
|
188 | + { |
|
189 | + return (is_null($this->path) ? '' : $this->path); |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * Sets the path portion of the URI. |
|
194 | + * |
|
195 | + * @param string $path |
|
196 | + * |
|
197 | + * @return self |
|
198 | + */ |
|
199 | + public function setPath(string $path): self |
|
200 | + { |
|
201 | + $this->path = $this->filterPath($path); |
|
202 | + |
|
203 | + $tempPath = trim($this->path, '/'); |
|
204 | + |
|
205 | + $this->filterSegments($tempPath); |
|
206 | + |
|
207 | + return $this; |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * Encodes any dangerous characters. |
|
212 | + * |
|
213 | + * @param string|null $path |
|
214 | + * |
|
215 | + * @return string |
|
216 | + */ |
|
217 | + protected function filterPath(string $path = null): string |
|
218 | + { |
|
219 | + $path = urldecode($path); |
|
220 | + |
|
221 | + return $path; |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * Filter the segments of path. |
|
226 | + * |
|
227 | + * @param string $uri |
|
228 | + * |
|
229 | + * @return string[] |
|
230 | + */ |
|
231 | + protected function filterSegments($uri) |
|
232 | + { |
|
233 | + $this->segments = ($uri === '') ? [] : explode('/', $uri); |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Get the specified URI segment, return default if it doesn't exist. |
|
238 | + * Segment index is 1 based, not 0 based. |
|
239 | + * |
|
240 | + * @param int $index The 1-based segment index |
|
241 | + * @param mixed $default The default value |
|
242 | + * |
|
243 | + * @return mixed |
|
244 | + */ |
|
245 | + public function getSegment(int $index, $default = null) |
|
246 | + { |
|
247 | + return Arr::get($this->getSegments(), $index - 1, $default); |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Returns the segments of the path as an array. |
|
252 | + * |
|
253 | + * @return array The URI segments |
|
254 | + */ |
|
255 | + public function getSegments() |
|
256 | + { |
|
257 | + return array_values(array_filter($this->segments, function ($value) { |
|
258 | + return $value != ''; |
|
259 | + })); |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Returns the total number of segment. |
|
264 | + * |
|
265 | + * @return int |
|
266 | + */ |
|
267 | + public function getTotalSegments(): int |
|
268 | + { |
|
269 | + return count($this->getSegments()); |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * Retrieve the scheme component of the URI. |
|
274 | + * |
|
275 | + * @return string |
|
276 | + */ |
|
277 | + public function getScheme(): string |
|
278 | + { |
|
279 | + return $this->scheme; |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * Sets the scheme for this URI. |
|
284 | + * |
|
285 | + * @param string $str |
|
286 | + * |
|
287 | + * @return string |
|
288 | + */ |
|
289 | + public function setScheme(string $str): string |
|
290 | + { |
|
291 | + $str = preg_replace('~:(//)?$~', '', strtolower($str)); |
|
292 | + |
|
293 | + $this->scheme = $str; |
|
294 | + |
|
295 | + return $this->scheme; |
|
296 | + } |
|
297 | + |
|
298 | + /** |
|
299 | + * Retrieve the user component of the URI. |
|
300 | + * |
|
301 | + * @return string|null |
|
302 | + */ |
|
303 | + public function getUserInfo() |
|
304 | + { |
|
305 | + $user = $this->user; |
|
306 | + $pass = $this->password; |
|
307 | + |
|
308 | + if ($this->showPassword === true && ! empty($pass)) { |
|
309 | + $user .= ":$pass"; |
|
310 | + } |
|
311 | + |
|
312 | + return $user; |
|
313 | + } |
|
314 | + |
|
315 | + /** |
|
316 | + * Sets the user portion of the URI. |
|
317 | + * |
|
318 | + * @param string $user |
|
319 | + * |
|
320 | + * @return string|null |
|
321 | + */ |
|
322 | + public function setUser($user): string |
|
323 | + { |
|
324 | + $this->user = trim($user); |
|
325 | + |
|
326 | + return $this->user; |
|
327 | + } |
|
328 | + |
|
329 | + /** |
|
330 | + * Sets the password portion of the URI. |
|
331 | + * |
|
332 | + * @param string $password |
|
333 | + * |
|
334 | + * @return string|null |
|
335 | + */ |
|
336 | + public function setPassword($password): string |
|
337 | + { |
|
338 | + $this->password = trim($password); |
|
339 | + |
|
340 | + return $this->password; |
|
341 | + } |
|
342 | + |
|
343 | + /** |
|
344 | + * Temporarily sets the URI to show a password in userInfo. |
|
345 | + * |
|
346 | + * @param boolean $option |
|
347 | + * |
|
348 | + * @return self |
|
349 | + */ |
|
350 | + public function showPassword(bool $option = true): self |
|
351 | + { |
|
352 | + $this->showPassword = $option; |
|
353 | + |
|
354 | + return $this; |
|
355 | + } |
|
356 | + |
|
357 | + /** |
|
358 | + * Retrieve the authority component of the URI. |
|
359 | + * |
|
360 | + * @param boolean $ignore |
|
361 | + * |
|
362 | + * @return string |
|
363 | + */ |
|
364 | + public function getAuthority(bool $ignore = false): string |
|
365 | + { |
|
366 | + if (empty($this->host)) { |
|
367 | + return ''; |
|
368 | + } |
|
369 | + |
|
370 | + $authority = $this->host; |
|
371 | + |
|
372 | + if ( ! empty($this->getUserInfo())) { |
|
373 | + $authority = $this->getUserInfo().'@'.$authority; |
|
374 | + } |
|
375 | + |
|
376 | + if ( ! empty($this->port) && ! $ignore) { |
|
377 | + if ($this->port !== $this->defaultPorts[$this->scheme]) { |
|
378 | + $authority .= ":$this->port"; |
|
379 | + } |
|
380 | + } |
|
381 | + |
|
382 | + $this->showPassword = false; |
|
383 | + |
|
384 | + return $authority; |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * Parses the given string an saves the appropriate authority pieces. |
|
389 | + * |
|
390 | + * @param string $str |
|
391 | + * |
|
392 | + * @return self |
|
393 | + */ |
|
394 | + public function setAuthority(string $str): self |
|
395 | + { |
|
396 | + $parts = parse_url($str); |
|
397 | + |
|
398 | + if (empty($parts['host']) && ! empty($parts['path'])) { |
|
399 | + $parts['host'] = $parts['path']; |
|
400 | + unset($parts['path']); |
|
401 | + } |
|
402 | + |
|
403 | + $this->applyParts($parts); |
|
404 | + |
|
405 | + return $this; |
|
406 | + } |
|
407 | + |
|
408 | + /** |
|
409 | + * Retrieve the host component of the URI. |
|
410 | + * |
|
411 | + * @return string |
|
412 | + */ |
|
413 | + public function getHost(): string |
|
414 | + { |
|
415 | + return $this->host; |
|
416 | + } |
|
417 | + |
|
418 | + /** |
|
419 | + * Sets the host name to use. |
|
420 | + * |
|
421 | + * @param string $str |
|
422 | + * |
|
423 | + * @return string |
|
424 | + */ |
|
425 | + public function setHost(string $str): string |
|
426 | + { |
|
427 | + $this->host = trim($str); |
|
428 | + |
|
429 | + return $this->host; |
|
430 | + } |
|
431 | + |
|
432 | + /** |
|
433 | + * Retrieve the port component of the URI. |
|
434 | + * |
|
435 | + * @return int|null |
|
436 | + */ |
|
437 | + public function getPort() |
|
438 | + { |
|
439 | + return $this->port; |
|
440 | + } |
|
441 | + |
|
442 | + /** |
|
443 | + * Sets the port portion of the URI. |
|
444 | + * |
|
445 | + * @param int|null $port |
|
446 | + * |
|
447 | + * @return string |
|
448 | + */ |
|
449 | + public function setPort(int $port = null): string |
|
450 | + { |
|
451 | + if (is_null($port)) { |
|
452 | + return $this; |
|
453 | + } |
|
454 | + |
|
455 | + if ($port <= 0 || $port > 65355) { |
|
456 | + throw HttpURIException::invalidPort($port); |
|
457 | + } |
|
458 | + |
|
459 | + $this->port = $port; |
|
460 | + |
|
461 | + return $this->port; |
|
462 | + } |
|
463 | + |
|
464 | + /** |
|
465 | + * Retrieve a URI fragment. |
|
466 | + * |
|
467 | + * @return string |
|
468 | + */ |
|
469 | + public function getFragment(): string |
|
470 | + { |
|
471 | + return is_null($this->fragment) ? '' : $this->fragment; |
|
472 | + } |
|
473 | + |
|
474 | + /** |
|
475 | + * Sets the fragment portion of the URI. |
|
476 | + * |
|
477 | + * @param string $str |
|
478 | + * |
|
479 | + * @return string |
|
480 | + */ |
|
481 | + public function setFragment(string $str): string |
|
482 | + { |
|
483 | + $this->fragment = trim($str, '# '); |
|
484 | + |
|
485 | + return $this->fragment; |
|
486 | + } |
|
487 | + |
|
488 | + /** |
|
489 | + * Saves our parts from a parse_url call. |
|
490 | + * |
|
491 | + * @param array $parts |
|
492 | + * |
|
493 | + * @return mixed |
|
494 | + */ |
|
495 | + public function applyParts(array $paths) |
|
496 | + { |
|
497 | + if (isset($parts['scheme'])) { |
|
498 | + $this->SetScheme(rtrim($parts['scheme'], ':/')); |
|
499 | + } else { |
|
500 | + $this->setScheme('http'); |
|
501 | + } |
|
502 | + |
|
503 | + if ( ! empty($parts['host'])) { |
|
504 | + $this->host = $parts['host']; |
|
505 | + } |
|
506 | + |
|
507 | + if (isset($parts['port'])) { |
|
508 | + if ( ! is_null($parts['port'])) { |
|
509 | + $this->port = $parts['port']; |
|
510 | + } |
|
511 | + } |
|
512 | + |
|
513 | + if ( ! empty($parts['user'])) { |
|
514 | + $this->user = $parts['user']; |
|
515 | + } |
|
516 | + |
|
517 | + if ( ! empty($parts['pass'])) { |
|
518 | + $this->password = $parts['pass']; |
|
519 | + } |
|
520 | + |
|
521 | + if ( ! empty($parts['path'])) { |
|
522 | + $this->path = $this->filterPath($parts['path']); |
|
523 | + } |
|
524 | + |
|
525 | + if ( ! empty($parts['fragment'])) { |
|
526 | + $this->fragment = $parts['fragment']; |
|
527 | + } |
|
528 | + |
|
529 | + if ( ! empty($parts['path'])) { |
|
530 | + $this->segments = explode('/', $parts['path'], '/'); |
|
531 | + } |
|
532 | + } |
|
533 | + |
|
534 | + /** |
|
535 | + * Magic method. |
|
536 | + * |
|
537 | + * Returns the URI string. |
|
538 | + * |
|
539 | + * @return string |
|
540 | + */ |
|
541 | + public function __toString() |
|
542 | + { |
|
543 | + return (string) $this->getPath(); |
|
544 | + } |
|
545 | 545 | } |
546 | 546 | \ No newline at end of file |
@@ -62,11 +62,11 @@ |
||
62 | 62 | */ |
63 | 63 | protected $locale; |
64 | 64 | |
65 | - /** |
|
66 | - * Boolean value whether the intl libraries exist on the system. |
|
67 | - * |
|
68 | - * @var bool $intlSupport |
|
69 | - */ |
|
65 | + /** |
|
66 | + * Boolean value whether the intl libraries exist on the system. |
|
67 | + * |
|
68 | + * @var bool $intlSupport |
|
69 | + */ |
|
70 | 70 | protected $intlSupport = false; |
71 | 71 | |
72 | 72 | /** |
@@ -356,7 +356,7 @@ |
||
356 | 356 | */ |
357 | 357 | public function regenerate($destroy = false) |
358 | 358 | { |
359 | - return take($this->migrate($destroy), function () { |
|
359 | + return take($this->migrate($destroy), function() { |
|
360 | 360 | $this->regenerateToken(); |
361 | 361 | }); |
362 | 362 | } |
@@ -170,7 +170,7 @@ |
||
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | - throw new ViewException(__('view.notFound', ['file' => $name])); |
|
173 | + throw new ViewException(__('view.notFound', ['file' => $name])); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -169,7 +169,7 @@ |
||
169 | 169 | */ |
170 | 170 | protected function getFindViewFiles($name): array |
171 | 171 | { |
172 | - return array_map(function ($extension) use ($name) { |
|
172 | + return array_map(function($extension) use ($name) { |
|
173 | 173 | return str_replace('.', DIRECTORY_SEPARATOR, $name).'.'.$extension; |
174 | 174 | }, $this->getExtensions()); |
175 | 175 | } |
@@ -21,10 +21,13 @@ |
||
21 | 21 | <?php endforeach; ?> |
22 | 22 | </tbody> |
23 | 23 | </table> |
24 | - <?php else : ?> |
|
24 | + <?php else { |
|
25 | + : ?> |
|
25 | 26 | <label class="empty"><?= e($label) ?></label> |
26 | 27 | <span class="empty"><?= e(__('exception.empty')) ?></span> |
27 | - <?php endif; ?> |
|
28 | + <?php endif; |
|
29 | +} |
|
30 | +?> |
|
28 | 31 | </div> |
29 | 32 | <?php endforeach; ?> |
30 | 33 | </div> |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | <div class="frame-info-class"> |
13 | 13 | <?php if ($frame->getClass() == '') : ?> |
14 | 14 | <span class="frame-function"><?= e($frame->getFunction()) ?></span> |
15 | - <?php else: ?> |
|
15 | + <?php else { |
|
16 | + : ?> |
|
16 | 17 | <span class="frame-class"><?= e($frame->getClass()) ?></span> |
17 | 18 | <?php if ($frame->getFunction() != '') : ?> |
18 | 19 | <span class="frame-function"><?= e($frame->getFunction()) ?></span> |
@@ -26,5 +27,7 @@ discard block |
||
26 | 27 | </div> |
27 | 28 | |
28 | 29 | </div> |
29 | -<?php endforeach; ?> |
|
30 | +<?php endforeach; |
|
31 | +} |
|
32 | +?> |
|
30 | 33 | </div> |
31 | 34 | \ No newline at end of file |