@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $this->setMethods($config['methods']); |
181 | 181 | $this->setScope($config['scope']); |
182 | 182 | $this->setPattern($config['pattern']); |
183 | - $this->setMiddleware((array)$config['middleware']); |
|
183 | + $this->setMiddleware((array) $config['middleware']); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function setMiddleware(array $middleware) |
193 | 193 | { |
194 | - $this->middleware = (array)$middleware; |
|
194 | + $this->middleware = (array) $middleware; |
|
195 | 195 | |
196 | 196 | return $this; |
197 | 197 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | { |
372 | 372 | $this->prefix = trim($prefix, '/'); |
373 | 373 | if ($this->prefix) { |
374 | - $this->prefix = '/' . $this->prefix; |
|
374 | + $this->prefix = '/'.$this->prefix; |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | return $this; |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | */ |
441 | 441 | public function setMethods($methods): self |
442 | 442 | { |
443 | - $methods = $methods ? (array)$methods : []; |
|
443 | + $methods = $methods ? (array) $methods : []; |
|
444 | 444 | $methods = array_map('strtoupper', $methods); |
445 | 445 | $methods = array_fill_keys($methods, true); |
446 | 446 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | */ |
464 | 464 | public function allow($methods = []) |
465 | 465 | { |
466 | - $methods = $methods ? (array)$methods : []; |
|
466 | + $methods = $methods ? (array) $methods : []; |
|
467 | 467 | $methods = array_map('strtoupper', $methods); |
468 | 468 | $methods = array_fill_keys($methods, true) + $this->methods; |
469 | 469 | |
@@ -523,10 +523,10 @@ discard block |
||
523 | 523 | $this->variables = null; |
524 | 524 | |
525 | 525 | if (!$pattern || $pattern[0] !== '[') { |
526 | - $pattern = '/' . trim($pattern, '/'); |
|
526 | + $pattern = '/'.trim($pattern, '/'); |
|
527 | 527 | } |
528 | 528 | |
529 | - $this->pattern = $this->prefix . $pattern; |
|
529 | + $this->pattern = $this->prefix.$pattern; |
|
530 | 530 | |
531 | 531 | return $this; |
532 | 532 | } |
@@ -640,9 +640,9 @@ discard block |
||
640 | 640 | } |
641 | 641 | } |
642 | 642 | |
643 | - $path = '/' . trim($path, '/'); |
|
643 | + $path = '/'.trim($path, '/'); |
|
644 | 644 | |
645 | - if (!preg_match('~^' . $this->regex() . '$~', $path, $matches)) { |
|
645 | + if (!preg_match('~^'.$this->regex().'$~', $path, $matches)) { |
|
646 | 646 | return false; |
647 | 647 | } |
648 | 648 | $variables = $this->_buildVariables($matches); |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | } else { |
675 | 675 | $token = $parser::tokenize($pattern, '/'); |
676 | 676 | $rule = $parser::compile($token); |
677 | - if (preg_match_all('~' . $rule[0] . '~', $values[$i], $parts)) { |
|
677 | + if (preg_match_all('~'.$rule[0].'~', $values[$i], $parts)) { |
|
678 | 678 | foreach ($parts[1] as $value) { |
679 | 679 | if (strpos($value, '/') !== false) { |
680 | 680 | $variables[$name][] = explode('/', $value); |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | |
706 | 706 | $generator = $this->middleware(); |
707 | 707 | |
708 | - $next = function () use ($request, $response, $generator, &$next) { |
|
708 | + $next = function() use ($request, $response, $generator, &$next) { |
|
709 | 709 | $handler = $generator->current(); |
710 | 710 | $generator->next(); |
711 | 711 | |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | } |
734 | 734 | } |
735 | 735 | |
736 | - yield function () { |
|
736 | + yield function() { |
|
737 | 737 | $handler = $this->handler(); |
738 | 738 | if ($handler === null) { |
739 | 739 | return null; |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | |
782 | 782 | $options = array_filter( |
783 | 783 | $options, |
784 | - function ($value) { |
|
784 | + function($value) { |
|
785 | 785 | return $value !== '*'; |
786 | 786 | } |
787 | 787 | ); |
@@ -793,24 +793,24 @@ discard block |
||
793 | 793 | |
794 | 794 | $basePath = trim($options['basePath'], '/'); |
795 | 795 | if ($basePath) { |
796 | - $basePath = '/' . $basePath; |
|
796 | + $basePath = '/'.$basePath; |
|
797 | 797 | } |
798 | 798 | $link = isset($link) ? ltrim($link, '/') : ''; |
799 | - $link = $basePath . ($link ? '/' . $link : $link); |
|
800 | - $query = $options['query'] ? '?' . $options['query'] : ''; |
|
801 | - $fragment = $options['fragment'] ? '#' . $options['fragment'] : ''; |
|
799 | + $link = $basePath.($link ? '/'.$link : $link); |
|
800 | + $query = $options['query'] ? '?'.$options['query'] : ''; |
|
801 | + $fragment = $options['fragment'] ? '#'.$options['fragment'] : ''; |
|
802 | 802 | |
803 | 803 | if ($options['absolute']) { |
804 | 804 | if ($this->host !== null) { |
805 | - $link = $this->host->link($params, $options) . "{$link}"; |
|
805 | + $link = $this->host->link($params, $options)."{$link}"; |
|
806 | 806 | } else { |
807 | - $scheme = !empty($options['scheme']) ? $options['scheme'] . '://' : '//'; |
|
807 | + $scheme = !empty($options['scheme']) ? $options['scheme'].'://' : '//'; |
|
808 | 808 | $host = isset($options['host']) ? $options['host'] : 'localhost'; |
809 | 809 | $link = "{$scheme}{$host}{$link}"; |
810 | 810 | } |
811 | 811 | } |
812 | 812 | |
813 | - return $link . $query . $fragment; |
|
813 | + return $link.$query.$fragment; |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | /** |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | if (isset($child['tokens'])) { |
832 | 832 | if ($child['repeat']) { |
833 | 833 | $name = $child['repeat']; |
834 | - $values = isset($params[$name]) && $params[$name] !== null ? (array)$params[$name] : []; |
|
834 | + $values = isset($params[$name]) && $params[$name] !== null ? (array) $params[$name] : []; |
|
835 | 835 | if (!$values && !$child['optional']) { |
836 | 836 | throw new RouterException("Missing parameters `'{$name}'` for route: `'{$this->name}#{$this->pattern}'`."); |
837 | 837 | } |
@@ -858,12 +858,12 @@ discard block |
||
858 | 858 | $parts = []; |
859 | 859 | } |
860 | 860 | foreach ($parts as $key => $value) { |
861 | - $parts[$key] = rawurlencode((string)$value); |
|
861 | + $parts[$key] = rawurlencode((string) $value); |
|
862 | 862 | } |
863 | 863 | $value = join('/', $parts); |
864 | 864 | |
865 | - if (!preg_match('~^' . $child['pattern'] . '$~', $value)) { |
|
866 | - throw new RouterException("Expected `'" . $child['name'] . "'` to match `'" . $child['pattern'] . "'`, but received `'" . $value . "'`."); |
|
865 | + if (!preg_match('~^'.$child['pattern'].'$~', $value)) { |
|
866 | + throw new RouterException("Expected `'".$child['name']."'` to match `'".$child['pattern']."'`, but received `'".$value."'`."); |
|
867 | 867 | } |
868 | 868 | $link .= $value; |
869 | 869 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | return false; |
221 | 221 | } |
222 | 222 | |
223 | - if (!preg_match('~^' . $this->getRegex() . '$~', $host, $matches)) { |
|
223 | + if (!preg_match('~^'.$this->getRegex().'$~', $host, $matches)) { |
|
224 | 224 | $hostVariables = null; |
225 | 225 | return false; |
226 | 226 | } |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | $options['host'] = $this->_link($this->getToken(), $params); |
247 | 247 | } |
248 | 248 | |
249 | - $scheme = $options['scheme'] !== '*' ? $options['scheme'] . '://' : '//'; |
|
249 | + $scheme = $options['scheme'] !== '*' ? $options['scheme'].'://' : '//'; |
|
250 | 250 | |
251 | - return $scheme . $options['host']; |
|
251 | + return $scheme.$options['host']; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -70,12 +70,12 @@ |
||
70 | 70 | \} |
71 | 71 | EOD; |
72 | 72 | /** |
73 | - * Tokenizes a route pattern. Optional segments are identified by square brackets. |
|
74 | - * |
|
75 | - * @param string $pattern A route pattern |
|
76 | - * @param string $delimiter The path delimiter. |
|
77 | - * @return array |
|
78 | - */ |
|
73 | + * Tokenizes a route pattern. Optional segments are identified by square brackets. |
|
74 | + * |
|
75 | + * @param string $pattern A route pattern |
|
76 | + * @param string $delimiter The path delimiter. |
|
77 | + * @return array |
|
78 | + */ |
|
79 | 79 | public static function tokenize(string $pattern, string $delimiter = '/'): array |
80 | 80 | { |
81 | 81 | // Checks if the pattern has some optional segments. |