@@ -34,24 +34,24 @@ discard block |
||
34 | 34 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
35 | 35 | { |
36 | 36 | $uri = $request->getUri(); |
37 | - if ($scheme = $uri->getScheme()) { $scheme .= ':';} |
|
37 | + if ($scheme = $uri->getScheme()) { $scheme .= ':'; } |
|
38 | 38 | $authority = $uri->getAuthority(); |
39 | 39 | $path = $uri->getPath(); |
40 | - if ($query = $uri->getQuery()) { $query = '?'.$query;}; |
|
41 | - if ($fragment = $uri->getFragment()) { $fragment = '#'.$fragment;}; |
|
40 | + if ($query = $uri->getQuery()) { $query = '?'.$query; }; |
|
41 | + if ($fragment = $uri->getFragment()) { $fragment = '#'.$fragment; }; |
|
42 | 42 | |
43 | 43 | // invariant part is not considered in match |
44 | 44 | $invariantUriPart = "$scheme//$authority"; |
45 | 45 | |
46 | 46 | // $matchSubject is the portion of the uri we are interest in |
47 | - $replacedUriPart=$this->appyRules($path.$query.$fragment); |
|
47 | + $replacedUriPart = $this->appyRules($path.$query.$fragment); |
|
48 | 48 | |
49 | - $parsedNewUrl = parse_url($invariantUriPart.$replacedUriPart ); |
|
49 | + $parsedNewUrl = parse_url($invariantUriPart.$replacedUriPart); |
|
50 | 50 | |
51 | 51 | $request = $request->withUri( |
52 | - $uri->withPath($parsedNewUrl['path']?:'') |
|
53 | - ->withQuery($parsedNewUrl['query']?:'') |
|
54 | - ->withFragment($parsedNewUrl['fragment']?:'') |
|
52 | + $uri->withPath($parsedNewUrl['path'] ?: '') |
|
53 | + ->withQuery($parsedNewUrl['query'] ?: '') |
|
54 | + ->withFragment($parsedNewUrl['fragment'] ?: '') |
|
55 | 55 | ); |
56 | 56 | |
57 | 57 | return $handler->handle($request); |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | */ |
64 | 64 | private function appyRules(string $subject): string |
65 | 65 | { |
66 | - foreach($this->rules as $pattern=>$replacement) { |
|
67 | - $pattern = '#^'. $pattern.'$#'; |
|
66 | + foreach ($this->rules as $pattern=>$replacement) { |
|
67 | + $pattern = '#^'.$pattern.'$#'; |
|
68 | 68 | $subject = preg_replace($pattern, $replacement, $subject); |
69 | - if( is_null($subject)){ |
|
69 | + if (is_null($subject)) { |
|
70 | 70 | throw new RuntimeException("Bad replacement '$pattern', '$replacement'"); |
71 | 71 | } |
72 | 72 | } |