@@ -45,18 +45,18 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | if (!function_exists('curl_init')) |
| 47 | 47 | { |
| 48 | - throw new CurlException("cURL is not available. This API wrapper cannot be used."); |
|
| 48 | + throw new CurlException("cURL is not available. This API wrapper cannot be used."); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if (isset($api_key)) |
| 52 | 52 | { |
| 53 | - $this->setApiKey($api_key); |
|
| 53 | + $this->setApiKey($api_key); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if ($basic === true) |
| 57 | 57 | { |
| 58 | - $this->_api_key_var = 'Authorization: Basic '; |
|
| 59 | - $this->json = false; |
|
| 58 | + $this->_api_key_var = 'Authorization: Basic '; |
|
| 59 | + $this->json = false; |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
@@ -117,16 +117,16 @@ discard block |
||
| 117 | 117 | curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_HEADER, true); |
| 118 | 118 | curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLINFO_HEADER_OUT, true); |
| 119 | 119 | if ($this->curlProxy) { |
| 120 | - curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_PROXY, $this->curlProxy); |
|
| 120 | + curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_PROXY, $this->curlProxy); |
|
| 121 | 121 | } |
| 122 | 122 | if ($this->_curl_callback) { |
| 123 | - call_user_func($this->_curl_callback, $ch, $params, $headers, $method); |
|
| 123 | + call_user_func($this->_curl_callback, $ch, $params, $headers, $method); |
|
| 124 | 124 | } |
| 125 | 125 | switch (strtoupper($method)) { |
| 126 | - case 'PATCH': |
|
| 126 | + case 'PATCH': |
|
| 127 | 127 | if (!empty($params)) { |
| 128 | - curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); |
|
| 129 | - curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_POSTFIELDS, json_encode($params)); |
|
| 128 | + curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); |
|
| 129 | + curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_POSTFIELDS, json_encode($params)); |
|
| 130 | 130 | } |
| 131 | 131 | break; |
| 132 | 132 | case 'DELETE': |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | $this->response = curl_exec(/** @scrutinizer ignore-type */ $ch); |
| 152 | 152 | |
| 153 | 153 | if (curl_errno(/** @scrutinizer ignore-type */ $ch)) { |
| 154 | - $this->curlErrno = curl_errno(/** @scrutinizer ignore-type */ $ch); |
|
| 155 | - $this->curlError = curl_error(/** @scrutinizer ignore-type */ $ch); |
|
| 156 | - curl_close(/** @scrutinizer ignore-type */ $ch); |
|
| 157 | - return; |
|
| 154 | + $this->curlErrno = curl_errno(/** @scrutinizer ignore-type */ $ch); |
|
| 155 | + $this->curlError = curl_error(/** @scrutinizer ignore-type */ $ch); |
|
| 156 | + curl_close(/** @scrutinizer ignore-type */ $ch); |
|
| 157 | + return; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $this->curlInfo = curl_getinfo(/** @scrutinizer ignore-type */ $ch); |
@@ -164,14 +164,14 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | private function _createHeaders($headers = null) |
| 166 | 166 | { |
| 167 | - $headers[] = $this->_api_key_var.$this->_api_key; |
|
| 168 | - if ($this->json === true) { |
|
| 169 | - $headers[] = 'Content-Type: application/json'; |
|
| 170 | - } |
|
| 171 | - if ($this->accept === true) { |
|
| 172 | - $headers[] = 'Accept: application/json'; |
|
| 173 | - } |
|
| 174 | - return $headers; |
|
| 167 | + $headers[] = $this->_api_key_var.$this->_api_key; |
|
| 168 | + if ($this->json === true) { |
|
| 169 | + $headers[] = 'Content-Type: application/json'; |
|
| 170 | + } |
|
| 171 | + if ($this->accept === true) { |
|
| 172 | + $headers[] = 'Accept: application/json'; |
|
| 173 | + } |
|
| 174 | + return $headers; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | private function _parseHeaders($raw_headers) |
@@ -206,12 +206,12 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | private function _getHeaders() |
| 208 | 208 | { |
| 209 | - return $this->_parseHeaders(substr($this->response, 0, $this->curlInfo['header_size'])); |
|
| 209 | + return $this->_parseHeaders(substr($this->response, 0, $this->curlInfo['header_size'])); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | private function _getBody() |
| 213 | 213 | { |
| 214 | - return substr($this->response, $this->curlInfo['header_size']); |
|
| 214 | + return substr($this->response, $this->curlInfo['header_size']); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | public function getResponse() |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | public function get($url, $params = null, $headers = null) |
| 228 | 228 | { |
| 229 | 229 | if (!empty($params)) { |
| 230 | - $url .= '?'.http_build_query($params); |
|
| 230 | + $url .= '?'.http_build_query($params); |
|
| 231 | 231 | } |
| 232 | 232 | return $this->_call($url, $params, $headers, $method = "GET"); |
| 233 | 233 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | public function post($url, $params = null, $headers = null) |
| 236 | 236 | { |
| 237 | 237 | if ($this->json === true) { |
| 238 | - $params = json_encode($params); |
|
| 238 | + $params = json_encode($params); |
|
| 239 | 239 | } |
| 240 | 240 | return $this->_call($url, $params, $headers, $method = "POST"); |
| 241 | 241 | } |