@@ -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 | |
@@ -75,25 +75,25 @@ discard block |
||
75 | 75 | $key = $uri; |
76 | 76 | $query = $request->getUri()->getQuery(); |
77 | 77 | if (strlen($query) > 0 && $this->queryInKey($uri)) { |
78 | - $key .= '?' . $query; |
|
78 | + $key .= '?'.$query; |
|
79 | 79 | } |
80 | 80 | |
81 | - return $this->cache->get($key)->then(function ($json) { |
|
81 | + return $this->cache->get($key)->then(function($json) { |
|
82 | 82 | $cachedResponse = json_decode($json); |
83 | - $headers = (array)$cachedResponse->headers; |
|
83 | + $headers = (array) $cachedResponse->headers; |
|
84 | 84 | // Todo at 2 October 2018 remove the check around this assignment |
85 | 85 | if (isset($cachedResponse->time)) { |
86 | - $headers['Age'] = (int)$this->clock->now()->format('U') - (string)$cachedResponse->time; |
|
86 | + $headers['Age'] = (int) $this->clock->now()->format('U') - (string) $cachedResponse->time; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return new Response($cachedResponse->code, $headers, stream_for($cachedResponse->body)); |
90 | - }, function () use ($next, $request, $key) { |
|
91 | - return resolve($next($request))->then(function (ResponseInterface $response) use ($key) { |
|
90 | + }, function() use ($next, $request, $key) { |
|
91 | + return resolve($next($request))->then(function(ResponseInterface $response) use ($key) { |
|
92 | 92 | if ($response->getBody() instanceof HttpBodyStream) { |
93 | 93 | return $response; |
94 | 94 | } |
95 | 95 | |
96 | - $body = (string)$response->getBody(); |
|
96 | + $body = (string) $response->getBody(); |
|
97 | 97 | $headers = []; |
98 | 98 | foreach ($this->headers as $header) { |
99 | 99 | if (!$response->hasHeader($header)) { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | 'body' => $body, |
107 | 107 | 'headers' => $headers, |
108 | 108 | 'code' => $response->getStatusCode(), |
109 | - 'time' => (int)$this->clock->now()->format('U'), |
|
109 | + 'time' => (int) $this->clock->now()->format('U'), |
|
110 | 110 | ]); |
111 | 111 | $this->cache->set($key, $cachedResponse); |
112 | 112 |