@@ -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 | |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function __invoke(callable $handler) |
| 112 | 112 | { |
| 113 | - return function (RequestInterface $request, array $options) use (&$handler) { |
|
| 113 | + return function(RequestInterface $request, array $options) use (&$handler) { |
|
| 114 | 114 | if (!isset($this->httpMethods[strtoupper($request->getMethod())])) { |
| 115 | 115 | // No caching for this method allowed |
| 116 | 116 | return $handler($request, $options)->then( |
| 117 | - function (ResponseInterface $response) { |
|
| 117 | + function(ResponseInterface $response) { |
|
| 118 | 118 | return $response->withHeader(self::HEADER_CACHE_INFO, self::HEADER_CACHE_MISS); |
| 119 | 119 | } |
| 120 | 120 | ); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $promise = $handler($request, $options); |
| 184 | 184 | |
| 185 | 185 | return $promise->then( |
| 186 | - function (ResponseInterface $response) use ($request, $cacheEntry) { |
|
| 186 | + function(ResponseInterface $response) use ($request, $cacheEntry) { |
|
| 187 | 187 | // Check if error and looking for a staled content |
| 188 | 188 | if ($response->getStatusCode() >= 500) { |
| 189 | 189 | $responseStale = static::getStaleResponse($cacheEntry); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | return static::addToCache($this->cacheStorage, $request, $response, $update); |
| 222 | 222 | }, |
| 223 | - function ($reason) use ($cacheEntry) { |
|
| 223 | + function($reason) use ($cacheEntry) { |
|
| 224 | 224 | if ($reason instanceof TransferException) { |
| 225 | 225 | $response = static::getStaleResponse($cacheEntry); |
| 226 | 226 | if ($response instanceof ResponseInterface) { |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $request = $request->withHeader(self::HEADER_RE_VALIDATION, '1'); |
| 282 | 282 | $this->waitingRevalidate[] = $this->client |
| 283 | 283 | ->sendAsync($request) |
| 284 | - ->then(function (ResponseInterface $response) use ($request, &$cacheStorage, $cacheEntry) { |
|
| 284 | + ->then(function(ResponseInterface $response) use ($request, &$cacheStorage, $cacheEntry) { |
|
| 285 | 285 | $update = false; |
| 286 | 286 | |
| 287 | 287 | if ($response->getStatusCode() == 304) { |
@@ -35,11 +35,11 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | public function save($key, CacheEntry $data) |
| 37 | 37 | { |
| 38 | - $ttl = $data->getTTL(); |
|
| 39 | - if ($ttl === 0) { |
|
| 38 | + $ttl = $data->getTTL(); |
|
| 39 | + if ($ttl === 0) { |
|
| 40 | 40 | return $this->cache->set($key, $data); |
| 41 | - } |
|
| 42 | - return $this->cache->set($key, $data, $data->getTTL()); |
|
| 41 | + } |
|
| 42 | + return $this->cache->set($key, $data, $data->getTTL()); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |