Completed
Pull Request — master (#74)
by John S
03:48
created
src/CacheMiddleware.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
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
                 );
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             $promise = $handler($request, $options);
178 178
 
179 179
             return $promise->then(
180
-                function (ResponseInterface $response) use ($request, $cacheEntry) {
180
+                function(ResponseInterface $response) use ($request, $cacheEntry) {
181 181
                     // Check if error and looking for a staled content
182 182
                     if ($response->getStatusCode() >= 500) {
183 183
                         $responseStale = static::getStaleResponse($cacheEntry);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
                     return $response;
204 204
                 },
205
-                function (\Exception $ex) use ($cacheEntry) {
205
+                function(\Exception $ex) use ($cacheEntry) {
206 206
                     if ($ex instanceof TransferException) {
207 207
                         $response = static::getStaleResponse($cacheEntry);
208 208
                         if ($response instanceof ResponseInterface) {
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      */
226 226
     protected function addReValidationRequest(
227 227
         RequestInterface $request,
228
-        CacheStrategyInterface &$cacheStorage,
228
+        CacheStrategyInterface & $cacheStorage,
229 229
         CacheEntry $cacheEntry
230 230
     ) {
231 231
         // Add the promise for revalidate
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             $request = $request->withHeader(self::HEADER_RE_VALIDATION, '1');
235 235
             $this->waitingRevalidate[] = $this->client
236 236
                 ->sendAsync($request)
237
-                ->then(function (ResponseInterface $response) use ($request, &$cacheStorage, $cacheEntry) {
237
+                ->then(function(ResponseInterface $response) use ($request, &$cacheStorage, $cacheEntry) {
238 238
                     if ($response->getStatusCode() == 304) {
239 239
                         // Not modified => cache entry is re-validate
240 240
                         /** @var ResponseInterface $response */
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
src/Strategy/PrivateCacheStrategy.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/CacheEntry.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.