private function __setRequestType($ch, $type = 'GET')
{
$this->current_method = strtoupper($type);
switch ($type) {
case 'GET':
break;
case 'POST':
curl_setopt($ch, CURLOPT_POST, true);
break;
case 'PUT':
curl_setopt($ch, CURLOPT_PUT, true);
break;
case 'DELETE':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
break;
case 'HEAD':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD');
curl_setopt($ch, CURLOPT_NOBODY, true);
break;
case 'OPTIONS':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'OPTIONS');
break;
default:
throw new \Exception('No request type is provided for request. Use post, put, delete, get or appropriate constants.');
}
}