@@ -93,7 +93,7 @@ |
||
93 | 93 | return new CacheEntry( |
94 | 94 | $request, |
95 | 95 | $response, |
96 | - new \DateTime('+'.(int) $cacheControl->get($key).'seconds') |
|
96 | + new \DateTime('+'.(int)$cacheControl->get($key).'seconds') |
|
97 | 97 | ); |
98 | 98 | } |
99 | 99 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | if ($staleIfErrorTo === null && $values->has('stale-if-error')) { |
72 | 72 | $this->staleIfErrorTo = (new \DateTime( |
73 | - '@'.($this->staleAt->getTimestamp() + (int) $values->get('stale-if-error')) |
|
73 | + '@'.($this->staleAt->getTimestamp() + (int)$values->get('stale-if-error')) |
|
74 | 74 | )); |
75 | 75 | } else { |
76 | 76 | $this->staleIfErrorTo = $staleIfErrorTo; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | if ($staleWhileRevalidateTo === null && $values->has('stale-while-revalidate')) { |
80 | 80 | $this->staleWhileRevalidateTo = new \DateTime( |
81 | - '@'.($this->staleAt->getTimestamp() + (int) $values->get('stale-while-revalidate')) |
|
81 | + '@'.($this->staleAt->getTimestamp() + (int)$values->get('stale-while-revalidate')) |
|
82 | 82 | ); |
83 | 83 | } else { |
84 | 84 | $this->staleWhileRevalidateTo = $staleWhileRevalidateTo; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $ttl = max($ttl, $this->staleAt->getTimestamp() - time()); |
247 | 247 | |
248 | 248 | // Don't return 0, it's reserved for infinite TTL |
249 | - return $ttl !== 0 ? (int) $ttl : -1; |
|
249 | + return $ttl !== 0 ? (int)$ttl : -1; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | private static function restoreStreamBody(MessageInterface $message): MessageInterface |
313 | 313 | { |
314 | 314 | return $message->withBody( |
315 | - \GuzzleHttp\Psr7\Utils::streamFor((string) $message->getBody()) |
|
315 | + \GuzzleHttp\Psr7\Utils::streamFor((string)$message->getBody()) |
|
316 | 316 | ); |
317 | 317 | } |
318 | 318 |
@@ -44,12 +44,12 @@ |
||
44 | 44 | */ |
45 | 45 | public function save($key, CacheEntry $data) |
46 | 46 | { |
47 | - try { |
|
47 | + try { |
|
48 | 48 | $this->filesystem->write($key, serialize($data)); |
49 | 49 | return true; |
50 | - } catch (FilesystemException $e) { |
|
50 | + } catch (FilesystemException $e) { |
|
51 | 51 | return false; |
52 | - } |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function __invoke(callable $handler) |
122 | 122 | { |
123 | - return function (RequestInterface $request, array $options) use (&$handler) { |
|
123 | + return function(RequestInterface $request, array $options) use (&$handler) { |
|
124 | 124 | if (!isset($this->httpMethods[strtoupper($request->getMethod())])) { |
125 | 125 | // No caching for this method allowed |
126 | 126 | |
127 | 127 | return $handler($request, $options)->then( |
128 | - function (ResponseInterface $response) use ($request) { |
|
128 | + function(ResponseInterface $response) use ($request) { |
|
129 | 129 | if (!isset($this->safeMethods[$request->getMethod()])) { |
130 | 130 | // Invalidate cache after a call of non-safe method on the same URI |
131 | 131 | $response = $this->invalidateCache($request, $response); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $promise = $handler($request, $options); |
200 | 200 | |
201 | 201 | return $promise->then( |
202 | - function (ResponseInterface $response) use ($request, $cacheEntry) { |
|
202 | + function(ResponseInterface $response) use ($request, $cacheEntry) { |
|
203 | 203 | // Check if error and looking for a staled content |
204 | 204 | if ($response->getStatusCode() >= 500) { |
205 | 205 | $responseStale = static::getStaleResponse($cacheEntry); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | return static::addToCache($this->cacheStorage, $request, $response, $update); |
238 | 238 | }, |
239 | - function ($reason) use ($cacheEntry) { |
|
239 | + function($reason) use ($cacheEntry) { |
|
240 | 240 | $response = static::getStaleResponse($cacheEntry); |
241 | 241 | if ($response instanceof ResponseInterface) { |
242 | 242 | return $response; |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | */ |
294 | 294 | protected function addReValidationRequest( |
295 | 295 | RequestInterface $request, |
296 | - CacheStrategyInterface &$cacheStorage, |
|
296 | + CacheStrategyInterface & $cacheStorage, |
|
297 | 297 | CacheEntry $cacheEntry |
298 | 298 | ) { |
299 | 299 | // Add the promise for revalidate |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | $request = $request->withHeader(static::HEADER_RE_VALIDATION, '1'); |
303 | 303 | $this->waitingRevalidate[] = $this->client |
304 | 304 | ->sendAsync($request) |
305 | - ->then(function (ResponseInterface $response) use ($request, &$cacheStorage, $cacheEntry) { |
|
305 | + ->then(function(ResponseInterface $response) use ($request, &$cacheStorage, $cacheEntry) { |
|
306 | 306 | $update = false; |
307 | 307 | |
308 | 308 | if ($response->getStatusCode() == 304) { |