flush
[m6w6/seekat] / lib / API / Call / Result.php
index 22ce2efb29dbc4cf1ca17505107c88f00d8c7231..6e1d8f818f0251196d7d6cf158b6a76917ee485a 100644 (file)
@@ -24,16 +24,7 @@ final class Result
 
                $links = $this->checkResponseMeta($response);
                $type = $this->checkResponseType($response);
-
-               try {
-                       $data = $type->parseBody($response->getBody());
-               } catch (\Exception $e) {
-                       $this->api->getLogger()->error("response -> error: ".$e->getMessage(), [
-                               "url" => (string) $this->api->getUrl(),
-                       ]);
-
-                       throw $e;
-               }
+               $data = $this->checkResponseBody($response, $type);
 
                return $this->api = $this->api->with(compact("type", "data", "links"));
        }
@@ -74,4 +65,18 @@ final class Result
 
                return new API\ContentType($type);
        }
+
+       private function checkResponseBody(Response $response, API\ContentType $type) {
+               try {
+                       $data = $type->parseBody($response->getBody());
+               } catch (\Exception $e) {
+                       $this->api->getLogger()->error("response -> error: ".$e->getMessage(), [
+                               "url" => (string) $this->api->getUrl(),
+                       ]);
+
+                       throw $e;
+               }
+
+               return $data;
+       }
 }