@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | |
| 3 | 3 | namespace WyriHaximus\React\Http\Middleware; |
| 4 | 4 | |
@@ -88,20 +88,20 @@ discard block |
||
| 88 | 88 | $key = $uri; |
| 89 | 89 | $query = $request->getUri()->getQuery(); |
| 90 | 90 | if (strlen($query) > 0 && $this->queryInKey($uri)) { |
| 91 | - $key .= '?' . $query; |
|
| 91 | + $key .= '?'.$query; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return $this->cache->get($key)->then(function ($json) { |
|
| 94 | + return $this->cache->get($key)->then(function($json) { |
|
| 95 | 95 | $cachedResponse = json_decode($json); |
| 96 | - $headers = (array)$cachedResponse->headers; |
|
| 96 | + $headers = (array) $cachedResponse->headers; |
|
| 97 | 97 | // Todo at 2 October 2018 remove the check around this assignment |
| 98 | 98 | if (isset($cachedResponse->time)) { |
| 99 | - $headers['Age'] = (int)$this->clock->now()->format('U') - (string)$cachedResponse->time; |
|
| 99 | + $headers['Age'] = (int) $this->clock->now()->format('U') - (string) $cachedResponse->time; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | return new Response($cachedResponse->code, $headers, stream_for($cachedResponse->body)); |
| 103 | - }, function () use ($next, $request, $key, $session) { |
|
| 104 | - return resolve($next($request))->then(function (ResponseInterface $response) use ($key, $session) { |
|
| 103 | + }, function() use ($next, $request, $key, $session) { |
|
| 104 | + return resolve($next($request))->then(function(ResponseInterface $response) use ($key, $session) { |
|
| 105 | 105 | if ($response->getBody() instanceof HttpBodyStream) { |
| 106 | 106 | return $response; |
| 107 | 107 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | return $response; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $body = (string)$response->getBody(); |
|
| 113 | + $body = (string) $response->getBody(); |
|
| 114 | 114 | $headers = []; |
| 115 | 115 | foreach ($this->headers as $header) { |
| 116 | 116 | if (!$response->hasHeader($header)) { |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | 'body' => $body, |
| 124 | 124 | 'headers' => $headers, |
| 125 | 125 | 'code' => $response->getStatusCode(), |
| 126 | - 'time' => (int)$this->clock->now()->format('U'), |
|
| 126 | + 'time' => (int) $this->clock->now()->format('U'), |
|
| 127 | 127 | ]); |
| 128 | 128 | $this->cache->set($key, $cachedResponse); |
| 129 | 129 | |