From 30b4aa5e9a2526870e8d461ed00a92677aa5ac9d Mon Sep 17 00:00:00 2001 From: temirkhan Date: Wed, 20 Apr 2016 12:00:50 +0300 Subject: [PATCH] Little fix in responseHandler switch case: throwing exception prevents next code execution, so it was unnecessary to use breaks. And also use return in case that differs from 200 --- src/Mailgun/Connection/RestClient.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Mailgun/Connection/RestClient.php b/src/Mailgun/Connection/RestClient.php index 270c1bc..bb67f8e 100644 --- a/src/Mailgun/Connection/RestClient.php +++ b/src/Mailgun/Connection/RestClient.php @@ -206,24 +206,18 @@ class RestClient $result = new \stdClass(); // return response data as json if possible, raw if not $result->http_response_body = $data && $jsonResponseData === null ? $data : $jsonResponseData; - break; + $result->http_response_code = $httpResponseCode; + + return $result; case 400: throw new MissingRequiredParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_PARAMETERS . $this->getResponseExceptionMessage($responseObj)); - break; case 401: throw new InvalidCredentials(ExceptionMessages::EXCEPTION_INVALID_CREDENTIALS); - break; case 404: throw new MissingEndpoint(ExceptionMessages::EXCEPTION_MISSING_ENDPOINT . $this->getResponseExceptionMessage($responseObj)); - break; default: throw new GenericHTTPError(ExceptionMessages::EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody()); - break; } - - $result->http_response_code = $httpResponseCode; - - return $result; } /**