Completed
Push — master ( 698ef7...d8ab97 )
by PHPLicengine
03:03 queued 01:01
created
lib/PHPLicengine/Api/Api.php 1 patch
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -26,237 +26,237 @@
 block discarded – undo
26 26
 
27 27
 class Api implements ApiInterface {
28 28
 
29
-           protected $_api_key_var = 'Authorization: Bearer ';
30
-           protected $_api_key;
31
-           protected $_timeout = 30;
32
-           protected $_verify_ssl = true;
33
-           protected $_verify_host = 2;
34
-           protected $curlErrno = false;
35
-           protected $curlError = false;
36
-           protected $curlProxy = false;
37
-           protected $response = false;
38
-           protected $request = array();
39
-           protected $json = true;
40
-           protected $curlInfo;
41
-           protected $_curl_callback;
29
+              protected $_api_key_var = 'Authorization: Bearer ';
30
+              protected $_api_key;
31
+              protected $_timeout = 30;
32
+              protected $_verify_ssl = true;
33
+              protected $_verify_host = 2;
34
+              protected $curlErrno = false;
35
+              protected $curlError = false;
36
+              protected $curlProxy = false;
37
+              protected $response = false;
38
+              protected $request = array();
39
+              protected $json = true;
40
+              protected $curlInfo;
41
+              protected $_curl_callback;
42 42
            
43
-           public function __construct($api_key = "", $basic = false) 
44
-           { 
45
-                  if (!function_exists('curl_init')) 
46
-                  { 
47
-                      throw new CurlException ("cURL is not available. This API wrapper cannot be used."); 
48
-                  } 
43
+              public function __construct($api_key = "", $basic = false) 
44
+              { 
45
+                     if (!function_exists('curl_init')) 
46
+                     { 
47
+                            throw new CurlException ("cURL is not available. This API wrapper cannot be used."); 
48
+                     } 
49 49
                   
50
-                  if (isset($api_key))
51
-                  {
52
-                      $this->setApiKey($api_key);
53
-                  } 
50
+                     if (isset($api_key))
51
+                     {
52
+                            $this->setApiKey($api_key);
53
+                     } 
54 54
                   
55
-                  if ($basic == true) 
56
-                  {
57
-                      $this->_api_key_var = 'Authorization: Basic ';
58
-                      $this->json = false;
59
-                  }
60
-           }
55
+                     if ($basic == true) 
56
+                     {
57
+                            $this->_api_key_var = 'Authorization: Basic ';
58
+                            $this->json = false;
59
+                     }
60
+              }
61 61
 
62
-           public function enableJson() 
63
-           {
64
-                  $this->_api_key_var = 'Authorization: Bearer ';
65
-                  $this->json = true;
66
-           } 
62
+              public function enableJson() 
63
+              {
64
+                     $this->_api_key_var = 'Authorization: Bearer ';
65
+                     $this->json = true;
66
+              } 
67 67
            
68
-           public function setApiKey($api_key) 
69
-           { 
70
-                  $this->_api_key = $api_key;
71
-           } 
68
+              public function setApiKey($api_key) 
69
+              { 
70
+                     $this->_api_key = $api_key;
71
+              } 
72 72
 
73
-           public function enableSslVerification() 
74
-           { 
75
-                  $this->_verify_ssl = true; 
76
-                  $this->_verify_host = 2; 
77
-           } 
73
+              public function enableSslVerification() 
74
+              { 
75
+                     $this->_verify_ssl = true; 
76
+                     $this->_verify_host = 2; 
77
+              } 
78 78
   
79
-           public function disableSslVerification() 
80
-           { 
81
-                  $this->_verify_ssl = false; 
82
-                  $this->_verify_host = 0; 
83
-           } 
79
+              public function disableSslVerification() 
80
+              { 
81
+                     $this->_verify_ssl = false; 
82
+                     $this->_verify_host = 0; 
83
+              } 
84 84
 
85
-           public function setTimeout($timeout) 
86
-           { 
87
-                  $this->_timeout = $timeout; 
88
-           } 
85
+              public function setTimeout($timeout) 
86
+              { 
87
+                     $this->_timeout = $timeout; 
88
+              } 
89 89
 
90
-           public function setCurlProxy($proxy)  
91
-           {  
92
-                  $this->curlProxy = $proxy;  
93
-           }  
90
+              public function setCurlProxy($proxy)  
91
+              {  
92
+                     $this->curlProxy = $proxy;  
93
+              }  
94 94
 
95
-           public function setCurlCallback($callback) 
96
-           { 
97
-                  $this->_curl_callback = $callback; 
98
-           } 
95
+              public function setCurlCallback($callback) 
96
+              { 
97
+                     $this->_curl_callback = $callback; 
98
+              } 
99 99
 
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':              
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 119
                           case 'PATCH':
120 120
                           case 'DELETE':
121 121
                                       curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method));
122
-                                      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
123
-                          break;
124
-                          case 'POST':
122
+                                          curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
123
+                            break;
124
+                            case 'POST':
125 125
                                       curl_setopt($ch, CURLOPT_POST, true);
126
-                                      if ($this->json === true) {
126
+                                          if ($this->json === true) {
127 127
                                           $params = json_encode($params);
128
-                                      }
129
-                                      curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
130
-                          break;
131
-                          case 'GET':
128
+                                          }
129
+                                          curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
130
+                            break;
131
+                            case 'GET':
132 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
-                  }
133
+                                          if (!empty($params)) {
134
+                                          $url .= '?' . http_build_query($params);
135
+                                          curl_setopt($ch, CURLOPT_URL, $url);
136
+                                          }
137
+                            break;
138
+                     }
139 139
 
140
-                  $headers[] = $this->_api_key_var.$this->_api_key;
141
-                  if ($this->json === true) {
142
-                      $headers[] = 'Content-Type: application/json';
143
-                  }
140
+                     $headers[] = $this->_api_key_var.$this->_api_key;
141
+                     if ($this->json === true) {
142
+                            $headers[] = 'Content-Type: application/json';
143
+                     }
144 144
                   
145
-                  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
145
+                     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
146 146
 
147
-                  $this->request['method'] = strtoupper($method);
148
-                  $this->request['headers'] = $headers;
149
-                  $this->request['params'] = $params;
147
+                     $this->request['method'] = strtoupper($method);
148
+                     $this->request['headers'] = $headers;
149
+                     $this->request['params'] = $params;
150 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
-           }
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
+              }
162 162
 
163
-           private function _parseHeaders($raw_headers) 
164
-           {
165
-                   if (!function_exists('http_parse_headers')) {
166
-                       $headers = array();
167
-                       $key = '';
163
+              private function _parseHeaders($raw_headers) 
164
+              {
165
+                     if (!function_exists('http_parse_headers')) {
166
+                            $headers = array();
167
+                            $key = '';
168 168
 
169
-                       foreach(explode("\n", $raw_headers) as $i => $h) {
170
-                               $h = explode(':', $h, 2);
169
+                            foreach(explode("\n", $raw_headers) as $i => $h) {
170
+                                   $h = explode(':', $h, 2);
171 171
 
172
-                               if (isset($h[1])) {
172
+                                   if (isset($h[1])) {
173 173
                                    if (!isset($headers[$h[0]]))
174
-                                       $headers[$h[0]] = trim($h[1]);
174
+                                          $headers[$h[0]] = trim($h[1]);
175 175
                                    elseif (is_array($headers[$h[0]])) {
176
-                                           $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
176
+                                                 $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
177 177
                                    }
178 178
                                    else {
179
-                                         $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
179
+                                          $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
180 180
                                    }
181 181
                                    $key = $h[0];
182
-                               }
183
-                               else { 
184
-                                     if (substr($h[0], 0, 1) == "\t")
185
-                                         $headers[$key] .= "\r\n\t".trim($h[0]);
186
-                                     elseif (!$key) 
187
-                                         $headers[0] = trim($h[0]); 
188
-                               }
189
-                       }
190
-                       return $headers;
182
+                                   }
183
+                                   else { 
184
+                                          if (substr($h[0], 0, 1) == "\t")
185
+                                          $headers[$key] .= "\r\n\t".trim($h[0]);
186
+                                          elseif (!$key) 
187
+                                          $headers[0] = trim($h[0]); 
188
+                                   }
189
+                            }
190
+                            return $headers;
191 191
                       
192
-                   } else {
193
-                       return http_parse_headers($raw_headers);
194
-                   } 
195
-           }
192
+                     } else {
193
+                            return http_parse_headers($raw_headers);
194
+                     } 
195
+              }
196 196
 
197
-           private function _getHeaders()
198
-           {
199
-                  return $this->_parseHeaders(substr($this->response, 0, $this->curlInfo['header_size']));
200
-           }
197
+              private function _getHeaders()
198
+              {
199
+                     return $this->_parseHeaders(substr($this->response, 0, $this->curlInfo['header_size']));
200
+              }
201 201
 
202
-           private function _getBody()
203
-           {
204
-                  return substr($this->response, $this->curlInfo['header_size']);
205
-           }
202
+              private function _getBody()
203
+              {
204
+                     return substr($this->response, $this->curlInfo['header_size']);
205
+              }
206 206
 
207
-           public function getResponse()
208
-           {
209
-                  return $this->response;      
210
-           }
207
+              public function getResponse()
208
+              {
209
+                     return $this->response;      
210
+              }
211 211
 
212
-           public function getRequest()
213
-           {
214
-                  return $this->request;
215
-           }
212
+              public function getRequest()
213
+              {
214
+                     return $this->request;
215
+              }
216 216
            
217
-           public function get($url, $params = null, $headers = null)
218
-           {
219
-                  return $this->_call($url, $params, $headers, $method = "GET");      
220
-           }
217
+              public function get($url, $params = null, $headers = null)
218
+              {
219
+                     return $this->_call($url, $params, $headers, $method = "GET");      
220
+              }
221 221
            
222
-           public function post($url, $params = null, $headers = null)
223
-           {
224
-                  return $this->_call($url, $params, $headers, $method = "POST");      
225
-           }
222
+              public function post($url, $params = null, $headers = null)
223
+              {
224
+                     return $this->_call($url, $params, $headers, $method = "POST");      
225
+              }
226 226
 
227
-           public function delete($url, $params = null, $headers = null) 
228
-           {
229
-                  return $this->_call($url, $params, $headers, $method = "DELETE");      
230
-           }
227
+              public function delete($url, $params = null, $headers = null) 
228
+              {
229
+                     return $this->_call($url, $params, $headers, $method = "DELETE");      
230
+              }
231 231
 
232
-           public function put($url, $params = null, $headers = null) 
233
-           {
234
-                  return $this->_call($url, $params, $headers, $method = "PUT");      
235
-           }
232
+              public function put($url, $params = null, $headers = null) 
233
+              {
234
+                     return $this->_call($url, $params, $headers, $method = "PUT");      
235
+              }
236 236
 
237
-           public function patch($url, $params = null, $headers = null) 
238
-           {
239
-                  return $this->_call($url, $params, $headers, $method = "PATCH");      
240
-           }
237
+              public function patch($url, $params = null, $headers = null) 
238
+              {
239
+                     return $this->_call($url, $params, $headers, $method = "PATCH");      
240
+              }
241 241
 
242
-           public function getCurlInfo()
243
-           {
244
-                  return $this->curlInfo;
245
-           }
242
+              public function getCurlInfo()
243
+              {
244
+                     return $this->curlInfo;
245
+              }
246 246
 
247
-           public function isCurlError () 
248
-           {
249
-                  return (bool) $this->curlErrno;
250
-           }
247
+              public function isCurlError () 
248
+              {
249
+                     return (bool) $this->curlErrno;
250
+              }
251 251
 
252
-           public function getCurlErrno () 
253
-           {
254
-                  return $this->curlErrno;
255
-           }
252
+              public function getCurlErrno () 
253
+              {
254
+                     return $this->curlErrno;
255
+              }
256 256
 
257
-           public function getCurlError () 
258
-           {
259
-                  return $this->curlError;
260
-           }
257
+              public function getCurlError () 
258
+              {
259
+                     return $this->curlError;
260
+              }
261 261
            
262 262
 }
Please login to merge, or discard this patch.
lib/PHPLicengine/Api/Result.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -25,161 +25,161 @@
 block discarded – undo
25 25
 
26 26
 class Result {
27 27
 
28
-      protected $error;
29
-      protected $message;
30
-      protected $headers;
31
-      protected $curlInfo;
32
-      protected $body;
33
-      protected $reasonPhrases = array(
34
-                // INFORMATIONAL CODES
35
-                100 => 'Continue',
36
-                101 => 'Switching Protocols',
37
-                102 => 'Processing',
38
-                // SUCCESS CODES
39
-                200 => 'OK',
40
-                201 => 'Created',
41
-                202 => 'Accepted',
42
-                203 => 'Non-Authoritative Information',
43
-                204 => 'No Content',
44
-                205 => 'Reset Content',
45
-                206 => 'Partial Content',
46
-                207 => 'Multi-status',
47
-                208 => 'Already Reported',
48
-                // REDIRECTION CODES
49
-                300 => 'Multiple Choices',
50
-                301 => 'Moved Permanently',
51
-                302 => 'Found',
52
-                303 => 'See Other',
53
-                304 => 'Not Modified',
54
-                305 => 'Use Proxy',
55
-                306 => 'Switch Proxy', // Deprecated
56
-                307 => 'Temporary Redirect',
57
-                // CLIENT ERROR
58
-                400 => 'Bad Request',
59
-                401 => 'Unauthorized',
60
-                402 => 'Payment Required',
61
-                403 => 'Forbidden',
62
-                404 => 'Not Found',
63
-                405 => 'Method Not Allowed',
64
-                406 => 'Not Acceptable',
65
-                407 => 'Proxy Authentication Required',
66
-                408 => 'Request Time-out',
67
-                409 => 'Conflict',
68
-                410 => 'Gone',
69
-                411 => 'Length Required',
70
-                412 => 'Precondition Failed',
71
-                413 => 'Request Entity Too Large',
72
-                414 => 'Request-URI Too Large',
73
-                415 => 'Unsupported Media Type',
74
-                416 => 'Requested range not satisfiable',
75
-                417 => 'Expectation Failed',
76
-                418 => 'I\'m a teapot',
77
-                422 => 'Unprocessable Entity',
78
-                423 => 'Locked',
79
-                424 => 'Failed Dependency',
80
-                425 => 'Unordered Collection',
81
-                426 => 'Upgrade Required',
82
-                428 => 'Precondition Required',
83
-                429 => 'Too Many Requests',
84
-                431 => 'Request Header Fields Too Large',
85
-                // SERVER ERROR
86
-                500 => 'Internal Server Error',
87
-                501 => 'Not Implemented',
88
-                502 => 'Bad Gateway',
89
-                503 => 'Service Unavailable',
90
-                504 => 'Gateway Time-out',
91
-                505 => 'HTTP Version not supported',
92
-                506 => 'Variant Also Negotiates',
93
-                507 => 'Insufficient Storage',
94
-                508 => 'Loop Detected',
95
-                511 => 'Network Authentication Required'
96
-      );
97
-
98
-      public function __construct($body, $headers, $curlInfo) 
99
-      {
100
-             $this->body = $body;
101
-             $this->headers = $headers;
102
-             $this->curlInfo = $curlInfo;
103
-      }
104
-
105
-      public function isError () 
106
-      {
107
-             return isset($this->getResponseObject()->errors) && $this->getResponseObject()->errors;
108
-      }
28
+       protected $error;
29
+       protected $message;
30
+       protected $headers;
31
+       protected $curlInfo;
32
+       protected $body;
33
+       protected $reasonPhrases = array(
34
+                     // INFORMATIONAL CODES
35
+                     100 => 'Continue',
36
+                     101 => 'Switching Protocols',
37
+                     102 => 'Processing',
38
+                     // SUCCESS CODES
39
+                     200 => 'OK',
40
+                     201 => 'Created',
41
+                     202 => 'Accepted',
42
+                     203 => 'Non-Authoritative Information',
43
+                     204 => 'No Content',
44
+                     205 => 'Reset Content',
45
+                     206 => 'Partial Content',
46
+                     207 => 'Multi-status',
47
+                     208 => 'Already Reported',
48
+                     // REDIRECTION CODES
49
+                     300 => 'Multiple Choices',
50
+                     301 => 'Moved Permanently',
51
+                     302 => 'Found',
52
+                     303 => 'See Other',
53
+                     304 => 'Not Modified',
54
+                     305 => 'Use Proxy',
55
+                     306 => 'Switch Proxy', // Deprecated
56
+                     307 => 'Temporary Redirect',
57
+                     // CLIENT ERROR
58
+                     400 => 'Bad Request',
59
+                     401 => 'Unauthorized',
60
+                     402 => 'Payment Required',
61
+                     403 => 'Forbidden',
62
+                     404 => 'Not Found',
63
+                     405 => 'Method Not Allowed',
64
+                     406 => 'Not Acceptable',
65
+                     407 => 'Proxy Authentication Required',
66
+                     408 => 'Request Time-out',
67
+                     409 => 'Conflict',
68
+                     410 => 'Gone',
69
+                     411 => 'Length Required',
70
+                     412 => 'Precondition Failed',
71
+                     413 => 'Request Entity Too Large',
72
+                     414 => 'Request-URI Too Large',
73
+                     415 => 'Unsupported Media Type',
74
+                     416 => 'Requested range not satisfiable',
75
+                     417 => 'Expectation Failed',
76
+                     418 => 'I\'m a teapot',
77
+                     422 => 'Unprocessable Entity',
78
+                     423 => 'Locked',
79
+                     424 => 'Failed Dependency',
80
+                     425 => 'Unordered Collection',
81
+                     426 => 'Upgrade Required',
82
+                     428 => 'Precondition Required',
83
+                     429 => 'Too Many Requests',
84
+                     431 => 'Request Header Fields Too Large',
85
+                     // SERVER ERROR
86
+                     500 => 'Internal Server Error',
87
+                     501 => 'Not Implemented',
88
+                     502 => 'Bad Gateway',
89
+                     503 => 'Service Unavailable',
90
+                     504 => 'Gateway Time-out',
91
+                     505 => 'HTTP Version not supported',
92
+                     506 => 'Variant Also Negotiates',
93
+                     507 => 'Insufficient Storage',
94
+                     508 => 'Loop Detected',
95
+                     511 => 'Network Authentication Required'
96
+       );
97
+
98
+       public function __construct($body, $headers, $curlInfo) 
99
+       {
100
+              $this->body = $body;
101
+              $this->headers = $headers;
102
+              $this->curlInfo = $curlInfo;
103
+       }
104
+
105
+       public function isError () 
106
+       {
107
+              return isset($this->getResponseObject()->errors) && $this->getResponseObject()->errors;
108
+       }
109 109
      
110
-      public function getDescription () 
111
-      {
112
-             return $this->getResponseObject()->description;
113
-      }
114
-
115
-      public function getHeaders()
116
-      {
117
-             return $this->headers;
118
-      }
119
-
120
-      public function getResponse()
121
-      {
122
-             return $this->body;
123
-      }
124
-
125
-      public function getResponseObject() 
126
-      {
127
-             return json_decode($this->body);
128
-      }
129
-
130
-      public function getResponseArray () 
131
-      {
132
-             return json_decode($this->body, true);
133
-      }
134
-
135
-      public function getResponseCode()
136
-      {
137
-             return $this->curlInfo['http_code'];
138
-      }
139
-
140
-      public function getReasonPhrase()
141
-      {
142
-             return $this->reasonPhrases[$this->curlInfo['http_code']];
143
-      }
144
-
145
-      public function getContentType()
146
-      {
147
-             return $this->curlInfo['content_type'];
148
-      }
149
-
150
-      public function isOk()
151
-      {
152
-             return ($this->curlInfo['http_code'] === 200);
153
-      }
154
-
155
-      public function isSuccess()
156
-      {
157
-             return (200 <= $this->curlInfo['http_code'] && 300 > $this->curlInfo['http_code']);
158
-      }
159
-
160
-      public function isNotFound()
161
-      {
162
-             return ($this->curlInfo['http_code'] === 404);
163
-      }
164
-
165
-      public function isInformational()
166
-      {
167
-             return ($this->curlInfo['http_code'] >= 100 && $this->curlInfo['http_code'] < 200);
168
-      }
169
-
170
-      public function isRedirect()
171
-      {
172
-             return (300 <= $this->curlInfo['http_code'] && 400 > $this->curlInfo['http_code']);
173
-      }
174
-
175
-      public function isClientError()
176
-      {
177
-             return ($this->curlInfo['http_code'] < 500 && $this->curlInfo['http_code'] >= 400);
178
-      }
179
-
180
-      public function isServerError()
181
-      {
182
-             return (500 <= $this->curlInfo['http_code'] && 600 > $this->curlInfo['http_code']);
183
-      }
110
+       public function getDescription () 
111
+       {
112
+              return $this->getResponseObject()->description;
113
+       }
114
+
115
+       public function getHeaders()
116
+       {
117
+              return $this->headers;
118
+       }
119
+
120
+       public function getResponse()
121
+       {
122
+              return $this->body;
123
+       }
124
+
125
+       public function getResponseObject() 
126
+       {
127
+              return json_decode($this->body);
128
+       }
129
+
130
+       public function getResponseArray () 
131
+       {
132
+              return json_decode($this->body, true);
133
+       }
134
+
135
+       public function getResponseCode()
136
+       {
137
+              return $this->curlInfo['http_code'];
138
+       }
139
+
140
+       public function getReasonPhrase()
141
+       {
142
+              return $this->reasonPhrases[$this->curlInfo['http_code']];
143
+       }
144
+
145
+       public function getContentType()
146
+       {
147
+              return $this->curlInfo['content_type'];
148
+       }
149
+
150
+       public function isOk()
151
+       {
152
+              return ($this->curlInfo['http_code'] === 200);
153
+       }
154
+
155
+       public function isSuccess()
156
+       {
157
+              return (200 <= $this->curlInfo['http_code'] && 300 > $this->curlInfo['http_code']);
158
+       }
159
+
160
+       public function isNotFound()
161
+       {
162
+              return ($this->curlInfo['http_code'] === 404);
163
+       }
164
+
165
+       public function isInformational()
166
+       {
167
+              return ($this->curlInfo['http_code'] >= 100 && $this->curlInfo['http_code'] < 200);
168
+       }
169
+
170
+       public function isRedirect()
171
+       {
172
+              return (300 <= $this->curlInfo['http_code'] && 400 > $this->curlInfo['http_code']);
173
+       }
174
+
175
+       public function isClientError()
176
+       {
177
+              return ($this->curlInfo['http_code'] < 500 && $this->curlInfo['http_code'] >= 400);
178
+       }
179
+
180
+       public function isServerError()
181
+       {
182
+              return (500 <= $this->curlInfo['http_code'] && 600 > $this->curlInfo['http_code']);
183
+       }
184 184
 
185 185
 }
Please login to merge, or discard this patch.
lib/PHPLicengine/Service/App.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -28,22 +28,22 @@
 block discarded – undo
28 28
 
29 29
 class App {
30 30
  
31
-      private $url;
32
-      private $api;
31
+       private $url;
32
+       private $api;
33 33
  
34
-      public function __construct (ApiInterface $api)
35
-      {
36
-             $this->api = $api;
37
-             $this->url = 'https://api-ssl.bitly.com/v4/apps';       
38
-      }
34
+       public function __construct (ApiInterface $api)
35
+       {
36
+              $this->api = $api;
37
+              $this->url = 'https://api-ssl.bitly.com/v4/apps';       
38
+       }
39 39
  
40
-      /*
40
+       /*
41 41
       Retrieve OAuth App
42 42
       https://dev.bitly.com/v4/#operation/getOAuthApp
43 43
       */
44
-      public function getOAuthApp(string $client_id) 
45
-      {
46
-             return $this->api->get($this->url . '/'.$client_id);
47
-      }
44
+       public function getOAuthApp(string $client_id) 
45
+       {
46
+              return $this->api->get($this->url . '/'.$client_id);
47
+       }
48 48
       
49 49
 }
Please login to merge, or discard this patch.