protected function validateHttpCode($response, $polling)
{
// Http response exceptions
switch (intval(trim($response['headers']['http_code']))) {
case 400:
throw new HttpExceptions\MissingCommandParameters((string) $response['headers']['http_code'], $response['headers']['url']);
break;
case 405:
throw new HttpExceptions\InvalidCommandMethod((string) $response['headers']['http_code'], $response['headers']['url']);
break;
case 500:
if (!$polling) {
throw new HttpExceptions\FailedCommand((string) $response['headers']['http_code'], $response['headers']['url']);
}
break;
case 501:
throw new HttpExceptions\UnimplementedCommand((string) $response['headers']['http_code'], $response['headers']['url']);
break;
default:
// Looks for 4xx http codes
if (preg_match("/^4[0-9][0-9]\$/", $response['headers']['http_code'])) {
throw new HttpExceptions\InvalidRequest((string) $response['headers']['http_code'], $response['headers']['url']);
}
break;
}
}