From 961ae177fa6d5aee353b204b2b5d27b2e0f42d7f Mon Sep 17 00:00:00 2001 From: David Garcia Date: Fri, 2 Feb 2018 00:18:51 +0000 Subject: [PATCH] Add new lines to improve readability --- src/Hydrator/ModelHydrator.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Hydrator/ModelHydrator.php b/src/Hydrator/ModelHydrator.php index b0f793d..9d6e1ea 100644 --- a/src/Hydrator/ModelHydrator.php +++ b/src/Hydrator/ModelHydrator.php @@ -29,11 +29,13 @@ final class ModelHydrator implements Hydrator { $body = $response->getBody()->__toString(); $contentType = $response->getHeaderLine('Content-Type'); + if (0 !== strpos($contentType, 'application/json') && 0 !== strpos($contentType, 'application/octet-stream')) { throw new HydrationException('The ModelHydrator cannot hydrate response with Content-Type: '.$contentType); } $data = json_decode($body, true); + if (JSON_ERROR_NONE !== json_last_error()) { throw new HydrationException(sprintf('Error (%d) when trying to json_decode response', json_last_error())); }