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
This commit is contained in:
temirkhan 2016-04-20 12:00:50 +03:00
parent 2d9cd57d2e
commit 30b4aa5e9a

View File

@ -206,24 +206,18 @@ class RestClient
$result = new \stdClass(); $result = new \stdClass();
// return response data as json if possible, raw if not // return response data as json if possible, raw if not
$result->http_response_body = $data && $jsonResponseData === null ? $data : $jsonResponseData; $result->http_response_body = $data && $jsonResponseData === null ? $data : $jsonResponseData;
break; $result->http_response_code = $httpResponseCode;
return $result;
case 400: case 400:
throw new MissingRequiredParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_PARAMETERS . $this->getResponseExceptionMessage($responseObj)); throw new MissingRequiredParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_PARAMETERS . $this->getResponseExceptionMessage($responseObj));
break;
case 401: case 401:
throw new InvalidCredentials(ExceptionMessages::EXCEPTION_INVALID_CREDENTIALS); throw new InvalidCredentials(ExceptionMessages::EXCEPTION_INVALID_CREDENTIALS);
break;
case 404: case 404:
throw new MissingEndpoint(ExceptionMessages::EXCEPTION_MISSING_ENDPOINT . $this->getResponseExceptionMessage($responseObj)); throw new MissingEndpoint(ExceptionMessages::EXCEPTION_MISSING_ENDPOINT . $this->getResponseExceptionMessage($responseObj));
break;
default: default:
throw new GenericHTTPError(ExceptionMessages::EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody()); throw new GenericHTTPError(ExceptionMessages::EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody());
break;
} }
$result->http_response_code = $httpResponseCode;
return $result;
} }
/** /**