X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fseekat;a=blobdiff_plain;f=lib%2FAPI%2FCall%2FResult.php;h=6e1d8f818f0251196d7d6cf158b6a76917ee485a;hp=22ce2efb29dbc4cf1ca17505107c88f00d8c7231;hb=e368287b3cd2dd40945ac8d1a1946bc32268007d;hpb=f4aa6beaf2e1f0dc9c877782cbbad5a989194517 diff --git a/lib/API/Call/Result.php b/lib/API/Call/Result.php index 22ce2ef..6e1d8f8 100644 --- a/lib/API/Call/Result.php +++ b/lib/API/Call/Result.php @@ -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; + } }