@@ -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 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | if ($staleIfErrorTo === null && $values->has('stale-if-error')) { |
| 78 | 78 | $this->staleIfErrorTo = (new \DateTime( |
| 79 | - '@'.($this->staleAt->getTimestamp() + (int) $values->get('stale-if-error')) |
|
| 79 | + '@'.($this->staleAt->getTimestamp() + (int)$values->get('stale-if-error')) |
|
| 80 | 80 | )); |
| 81 | 81 | } else { |
| 82 | 82 | $this->staleIfErrorTo = $staleIfErrorTo; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | if ($staleWhileRevalidateTo === null && $values->has('stale-while-revalidate')) { |
| 86 | 86 | $this->staleWhileRevalidateTo = new \DateTime( |
| 87 | - '@'.($this->staleAt->getTimestamp() + (int) $values->get('stale-while-revalidate')) |
|
| 87 | + '@'.($this->staleAt->getTimestamp() + (int)$values->get('stale-while-revalidate')) |
|
| 88 | 88 | ); |
| 89 | 89 | } else { |
| 90 | 90 | $this->staleWhileRevalidateTo = $staleWhileRevalidateTo; |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // Don't return 0, it's reserved for infinite TTL |
| 226 | - return $ttl !== 0 ? (int) $ttl : -1; |
|
| 226 | + return $ttl !== 0 ? (int)$ttl : -1; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | { |
| 239 | 239 | // Stream/Resource can't be serialized... So we copy the content |
| 240 | 240 | if ($this->response !== null) { |
| 241 | - $this->responseBody = (string) $this->response->getBody(); |
|
| 241 | + $this->responseBody = (string)$this->response->getBody(); |
|
| 242 | 242 | $this->response->getBody()->rewind(); |
| 243 | 243 | } |
| 244 | 244 | |
@@ -105,7 +105,7 @@ |
||
| 105 | 105 | /** |
| 106 | 106 | * @param callable $handler |
| 107 | 107 | * |
| 108 | - * @return callable |
|
| 108 | + * @return \Closure |
|
| 109 | 109 | */ |
| 110 | 110 | public function __invoke(callable $handler) |
| 111 | 111 | { |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function __invoke(callable $handler) |
| 111 | 111 | { |
| 112 | - return function (RequestInterface $request, array $options) use (&$handler) { |
|
| 112 | + return function(RequestInterface $request, array $options) use (&$handler) { |
|
| 113 | 113 | if (!isset($this->httpMethods[strtoupper($request->getMethod())])) { |
| 114 | 114 | // No caching for this method allowed |
| 115 | 115 | return $handler($request, $options)->then( |
| 116 | - function (ResponseInterface $response) { |
|
| 116 | + function(ResponseInterface $response) { |
|
| 117 | 117 | return $response->withHeader(self::HEADER_CACHE_INFO, self::HEADER_CACHE_MISS); |
| 118 | 118 | } |
| 119 | 119 | ); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $promise = $handler($request, $options); |
| 183 | 183 | |
| 184 | 184 | return $promise->then( |
| 185 | - function (ResponseInterface $response) use ($request, $cacheEntry) { |
|
| 185 | + function(ResponseInterface $response) use ($request, $cacheEntry) { |
|
| 186 | 186 | // Check if error and looking for a staled content |
| 187 | 187 | if ($response->getStatusCode() >= 500) { |
| 188 | 188 | $responseStale = static::getStaleResponse($cacheEntry); |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | return self::addToCache($this->cacheStorage, $request, $response, $update); |
| 217 | 217 | }, |
| 218 | - function (\Exception $ex) use ($cacheEntry) { |
|
| 218 | + function(\Exception $ex) use ($cacheEntry) { |
|
| 219 | 219 | if ($ex instanceof TransferException) { |
| 220 | 220 | $response = static::getStaleResponse($cacheEntry); |
| 221 | 221 | if ($response instanceof ResponseInterface) { |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | protected function addReValidationRequest( |
| 269 | 269 | RequestInterface $request, |
| 270 | - CacheStrategyInterface &$cacheStorage, |
|
| 270 | + CacheStrategyInterface & $cacheStorage, |
|
| 271 | 271 | CacheEntry $cacheEntry |
| 272 | 272 | ) { |
| 273 | 273 | // Add the promise for revalidate |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | $request = $request->withHeader(self::HEADER_RE_VALIDATION, '1'); |
| 277 | 277 | $this->waitingRevalidate[] = $this->client |
| 278 | 278 | ->sendAsync($request) |
| 279 | - ->then(function (ResponseInterface $response) use ($request, &$cacheStorage, $cacheEntry) { |
|
| 279 | + ->then(function(ResponseInterface $response) use ($request, &$cacheStorage, $cacheEntry) { |
|
| 280 | 280 | $update = false; |
| 281 | 281 | |
| 282 | 282 | if ($response->getStatusCode() == 304) { |