| Conditions | 12 | 
| Paths | 128 | 
| Total Lines | 61 | 
| Code Lines | 48 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 4 | ||
| Bugs | 0 | Features | 0 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 100 | private function _call($url, $params = null, $headers = null, $method = "GET")  | 
            ||
| 101 |               { | 
            ||
| 102 | $ch = curl_init();  | 
            ||
| 103 | curl_setopt($ch, CURLOPT_URL, $url);  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 104 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);  | 
            ||
| 105 | curl_setopt($ch, CURLOPT_TIMEOUT, $this->_timeout);  | 
            ||
| 106 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  | 
            ||
| 107 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->_verify_ssl);  | 
            ||
| 108 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->_verify_host);  | 
            ||
| 109 | curl_setopt($ch, CURLOPT_HEADER, true);  | 
            ||
| 110 | curl_setopt($ch, CURLINFO_HEADER_OUT, true);  | 
            ||
| 111 |                      if ($this->curlProxy) {   | 
            ||
| 112 | curl_setopt($ch, CURLOPT_PROXY, $this->curlProxy);  | 
            ||
| 113 | }  | 
            ||
| 114 |                      if ($this->_curl_callback) {  | 
            ||
| 115 | call_user_func($this->_curl_callback, $ch, $params, $headers, $method);  | 
            ||
| 116 | }  | 
            ||
| 117 |                      switch (strtoupper($method)) {  | 
            ||
| 118 | case 'PUT':  | 
            ||
| 119 | case 'PATCH':  | 
            ||
| 120 | case 'DELETE':  | 
            ||
| 121 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method));  | 
            ||
| 122 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));  | 
            ||
| 123 | break;  | 
            ||
| 124 | case 'POST':  | 
            ||
| 125 | curl_setopt($ch, CURLOPT_POST, true);  | 
            ||
| 126 |                                           if ($this->json === true) { | 
            ||
| 127 | $params = json_encode($params);  | 
            ||
| 128 | }  | 
            ||
| 129 | curl_setopt($ch, CURLOPT_POSTFIELDS, $params);  | 
            ||
| 130 | break;  | 
            ||
| 131 | case 'GET':  | 
            ||
| 132 | curl_setopt($ch, CURLOPT_HTTPGET, true);  | 
            ||
| 133 |                                           if (!empty($params)) { | 
            ||
| 134 | $url .= '?' . http_build_query($params);  | 
            ||
| 135 | curl_setopt($ch, CURLOPT_URL, $url);  | 
            ||
| 136 | }  | 
            ||
| 137 | break;  | 
            ||
| 138 | }  | 
            ||
| 139 | |||
| 140 | $headers[] = $this->_api_key_var.$this->_api_key;  | 
            ||
| 141 |                      if ($this->json === true) { | 
            ||
| 142 | $headers[] = 'Content-Type: application/json';  | 
            ||
| 143 | }  | 
            ||
| 144 | |||
| 145 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);  | 
            ||
| 146 | |||
| 147 | $this->request['method'] = strtoupper($method);  | 
            ||
| 148 | $this->request['headers'] = $headers;  | 
            ||
| 149 | $this->request['params'] = $params;  | 
            ||
| 150 | |||
| 151 | $this->response = curl_exec($ch);  | 
            ||
| 152 |                      if (curl_errno($ch)) { | 
            ||
| 153 | $this->curlErrno = curl_errno($ch);  | 
            ||
| 154 | $this->curlError = curl_error($ch);  | 
            ||
| 155 | curl_close($ch);  | 
            ||
| 156 | return;  | 
            ||
| 157 | }  | 
            ||
| 158 | $this->curlInfo = curl_getinfo($ch);  | 
            ||
| 159 | curl_close($ch);  | 
            ||
| 160 | return new Result($this->_getBody(), $this->_getHeaders(), $this->curlInfo);  | 
            ||
| 161 | }  | 
            ||
| 263 |