I got rating C by scrutinizer for class method below. Please help to improve it to get level A.
private function _call($url, $params = null, $headers = null, $method = "GET")
{
$ch = curl_init();
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_URL, $url);
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_TIMEOUT, $this->_timeout);
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_SSL_VERIFYPEER, $this->_verify_ssl);
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_SSL_VERIFYHOST, $this->_verify_host);
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_HEADER, true);
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLINFO_HEADER_OUT, true);
if ($this->curlProxy) {
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_PROXY, $this->curlProxy);
}
if ($this->_curl_callback) {
call_user_func($this->_curl_callback, $ch, $params, $headers, $method);
}
switch (strtoupper($method)) {
case 'PUT':
case 'PATCH':
case 'DELETE':
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_CUSTOMREQUEST, strtoupper($method));
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_POSTFIELDS, json_encode($params));
break;
case 'POST':
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_POST, true);
if ($this->json === true) {
$params = json_encode($params);
}
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_POSTFIELDS, $params);
break;
case 'GET':
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_HTTPGET, true);
if (!empty($params)) {
$url .= '?'.http_build_query($params);
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_URL, $url);
}
break;
}
$headers[] = $this->_api_key_var.$this->_api_key;
if ($this->json === true) {
$headers[] = 'Content-Type: application/json';
}
if ($this->accept === true) {
$headers[] = 'Accept: application/json';
}
curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_HTTPHEADER, $headers);
$this->request['method'] = strtoupper($method);
$this->request['headers'] = $headers;
$this->request['params'] = $params;
$this->response = curl_exec(/** @scrutinizer ignore-type */ $ch);
if (curl_errno(/** @scrutinizer ignore-type */ $ch)) {
$this->curlErrno = curl_errno(/** @scrutinizer ignore-type */ $ch);
$this->curlError = curl_error(/** @scrutinizer ignore-type */ $ch);
curl_close(/** @scrutinizer ignore-type */ $ch);
return;
}
$this->curlInfo = curl_getinfo(/** @scrutinizer ignore-type */ $ch);
curl_close(/** @scrutinizer ignore-type */ $ch);
return new Result($this->_getBody(), $this->_getHeaders(), $this->curlInfo);
}