diff --git a/src/Mailgun/Exception/DeserializeException.php b/src/Mailgun/Exception/HydrationException.php similarity index 74% rename from src/Mailgun/Exception/DeserializeException.php rename to src/Mailgun/Exception/HydrationException.php index 2942869..0647a01 100644 --- a/src/Mailgun/Exception/DeserializeException.php +++ b/src/Mailgun/Exception/HydrationException.php @@ -11,6 +11,6 @@ namespace Mailgun\Exception; use Mailgun\Exception; -final class DeserializeException extends \RuntimeException implements Exception +final class HydrationException extends \RuntimeException implements Exception { } diff --git a/src/Mailgun/Hydrator/ArrayHydrator.php b/src/Mailgun/Hydrator/ArrayHydrator.php index 700be80..4174a5e 100644 --- a/src/Mailgun/Hydrator/ArrayHydrator.php +++ b/src/Mailgun/Hydrator/ArrayHydrator.php @@ -9,7 +9,7 @@ namespace Mailgun\Hydrator; -use Mailgun\Exception\DeserializeException; +use Mailgun\Exception\HydrationException; use Psr\Http\Message\ResponseInterface; /** @@ -29,12 +29,12 @@ final class ArrayHydrator implements Hydrator { $body = $response->getBody()->__toString(); if (strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) { - throw new DeserializeException('The ArrayHydrator cannot hydrate response with Content-Type:'.$response->getHeaderLine('Content-Type')); + throw new HydrationException('The ArrayHydrator cannot hydrate response with Content-Type:'.$response->getHeaderLine('Content-Type')); } $content = json_decode($body, true); if (JSON_ERROR_NONE !== json_last_error()) { - throw new DeserializeException(sprintf('Error (%d) when trying to json_decode response', json_last_error())); + throw new HydrationException(sprintf('Error (%d) when trying to json_decode response', json_last_error())); } return $content; diff --git a/src/Mailgun/Hydrator/Hydrator.php b/src/Mailgun/Hydrator/Hydrator.php index 212c3c3..ac03eb0 100644 --- a/src/Mailgun/Hydrator/Hydrator.php +++ b/src/Mailgun/Hydrator/Hydrator.php @@ -9,6 +9,7 @@ namespace Mailgun\Hydrator; +use Mailgun\Exception\HydrationException; use Psr\Http\Message\ResponseInterface; /** @@ -21,6 +22,8 @@ interface Hydrator * @param string $class * * @return mixed + * + * @throws HydrationException */ public function hydrate(ResponseInterface $response, $class); } diff --git a/src/Mailgun/Hydrator/ModelHydrator.php b/src/Mailgun/Hydrator/ModelHydrator.php index 595518a..83836c3 100644 --- a/src/Mailgun/Hydrator/ModelHydrator.php +++ b/src/Mailgun/Hydrator/ModelHydrator.php @@ -9,7 +9,7 @@ namespace Mailgun\Hydrator; -use Mailgun\Exception\DeserializeException; +use Mailgun\Exception\HydrationException; use Mailgun\Model\ApiResponse; use Psr\Http\Message\ResponseInterface; @@ -31,12 +31,12 @@ final class ModelHydrator implements Hydrator $body = $response->getBody()->__toString(); $contentType = $response->getHeaderLine('Content-Type'); if (strpos($contentType, 'application/json') !== 0 && strpos($contentType, 'application/octet-stream') !== 0) { - throw new DeserializeException('The ModelHydrator cannot hydrate response with Content-Type: '.$contentType); + 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 DeserializeException(sprintf('Error (%d) when trying to json_decode response', json_last_error())); + throw new HydrationException(sprintf('Error (%d) when trying to json_decode response', json_last_error())); } if (is_subclass_of($class, ApiResponse::class)) {