@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | |
41 | 41 | $key = $this->cacheConfiguration->cacheKey($request); |
42 | 42 | |
43 | - return $this->cache->get($key)->then(function ($json) use ($next, $request, $key) { |
|
43 | + return $this->cache->get($key)->then(function($json) use ($next, $request, $key) { |
|
44 | 44 | if ($json !== null) { |
45 | 45 | return $this->cacheConfiguration->cacheDecode($json); |
46 | 46 | } |
47 | 47 | |
48 | - return resolve($next($request))->then(function (ResponseInterface $response) use ($request, $key) { |
|
48 | + return resolve($next($request))->then(function(ResponseInterface $response) use ($request, $key) { |
|
49 | 49 | if ($response->getBody() instanceof HttpBodyStream) { |
50 | 50 | return $response; |
51 | 51 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | $ttl = $this->cacheConfiguration->cacheTtl($request, $response); |
58 | - $body = (string)$response->getBody(); |
|
58 | + $body = (string) $response->getBody(); |
|
59 | 59 | $encodedResponse = $this->cacheConfiguration->cacheEncode($response->withBody(stream_for($body))); |
60 | 60 | $this->cache->set($key, $encodedResponse, $ttl); |
61 | 61 |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $key = $request->getUri()->getPath(); |
87 | 87 | $query = $request->getUri()->getQuery(); |
88 | 88 | if (\strlen($query) > 0 && $this->queryInKey($key)) { |
89 | - $key .= '?' . $query; |
|
89 | + $key .= '?'.$query; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | return $key; |
@@ -114,17 +114,17 @@ discard block |
||
114 | 114 | |
115 | 115 | return msgpack_pack([ |
116 | 116 | 'code' => $response->getStatusCode(), |
117 | - 'time' => (int)$this->clock->now()->format('U'), |
|
117 | + 'time' => (int) $this->clock->now()->format('U'), |
|
118 | 118 | 'headers' => $headers, |
119 | - 'body' => (string)$response->getBody(), |
|
119 | + 'body' => (string) $response->getBody(), |
|
120 | 120 | ]); |
121 | 121 | } |
122 | 122 | |
123 | 123 | public function cacheDecode(string $response): ResponseInterface |
124 | 124 | { |
125 | 125 | $response = msgpack_unpack($response); |
126 | - $response['headers'] = (array)$response['headers']; |
|
127 | - $response['headers']['Age'] = (int)$this->clock->now()->format('U') - (int)$response['time']; |
|
126 | + $response['headers'] = (array) $response['headers']; |
|
127 | + $response['headers']['Age'] = (int) $this->clock->now()->format('U') - (int) $response['time']; |
|
128 | 128 | |
129 | 129 | return new Response($response['code'], $response['headers'], stream_for($response['body'])); |
130 | 130 | } |