@@ -28,22 +28,22 @@ |
||
| 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 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | private $url; |
| 32 | 32 | private $api; |
| 33 | 33 | |
| 34 | - public function __construct (ApiInterface $api) |
|
| 34 | + public function __construct(ApiInterface $api) |
|
| 35 | 35 | { |
| 36 | 36 | $this->api = $api; |
| 37 | 37 | $this->url = 'https://api-ssl.bitly.com/v4/apps'; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function getOAuthApp(string $client_id) |
| 45 | 45 | { |
| 46 | - return $this->api->get($this->url . '/'.$client_id); |
|
| 46 | + return $this->api->get($this->url.'/'.$client_id); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | } |
@@ -25,15 +25,15 @@ |
||
| 25 | 25 | |
| 26 | 26 | interface ApiInterface |
| 27 | 27 | { |
| 28 | - public function get($url, $params = null, $headers = null); |
|
| 28 | + public function get($url, $params = null, $headers = null); |
|
| 29 | 29 | |
| 30 | - public function post($url, $params = null, $headers = null); |
|
| 30 | + public function post($url, $params = null, $headers = null); |
|
| 31 | 31 | |
| 32 | - public function delete($url, $params = null, $headers = null); |
|
| 32 | + public function delete($url, $params = null, $headers = null); |
|
| 33 | 33 | |
| 34 | - public function put($url, $params = null, $headers = null); |
|
| 34 | + public function put($url, $params = null, $headers = null); |
|
| 35 | 35 | |
| 36 | - public function patch($url, $params = null, $headers = null); |
|
| 36 | + public function patch($url, $params = null, $headers = null); |
|
| 37 | 37 | |
| 38 | - public function setApiKey($api_key); |
|
| 38 | + public function setApiKey($api_key); |
|
| 39 | 39 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | if (!function_exists('curl_init')) |
| 46 | 46 | { |
| 47 | - throw new CurlException ("cURL is not available. This API wrapper cannot be used."); |
|
| 47 | + throw new CurlException("cURL is not available. This API wrapper cannot be used."); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | if (isset($api_key)) |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | case 'GET': |
| 132 | 132 | curl_setopt(resource $ch, CURLOPT_HTTPGET, true); |
| 133 | 133 | if (!empty($params)) { |
| 134 | - $url .= '?' . http_build_query($params); |
|
| 134 | + $url .= '?'.http_build_query($params); |
|
| 135 | 135 | curl_setopt(resource $ch, CURLOPT_URL, $url); |
| 136 | 136 | } |
| 137 | 137 | break; |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $headers = array(); |
| 167 | 167 | $key = ''; |
| 168 | 168 | |
| 169 | - foreach(explode("\n", $raw_headers) as $i => $h) { |
|
| 169 | + foreach (explode("\n", $raw_headers) as $i => $h) { |
|
| 170 | 170 | $h = explode(':', $h, 2); |
| 171 | 171 | |
| 172 | 172 | if (isset($h[1])) { |
@@ -244,17 +244,17 @@ discard block |
||
| 244 | 244 | return $this->curlInfo; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - public function isCurlError () |
|
| 247 | + public function isCurlError() |
|
| 248 | 248 | { |
| 249 | 249 | return (bool) $this->curlErrno; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - public function getCurlErrno () |
|
| 252 | + public function getCurlErrno() |
|
| 253 | 253 | { |
| 254 | 254 | return $this->curlErrno; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - public function getCurlError () |
|
| 257 | + public function getCurlError() |
|
| 258 | 258 | { |
| 259 | 259 | return $this->curlError; |
| 260 | 260 | } |
@@ -170,21 +170,20 @@ |
||
| 170 | 170 | $h = explode(':', $h, 2); |
| 171 | 171 | |
| 172 | 172 | if (isset($h[1])) { |
| 173 | - if (!isset($headers[$h[0]])) |
|
| 174 | - $headers[$h[0]] = trim($h[1]); |
|
| 175 | - elseif (is_array($headers[$h[0]])) { |
|
| 173 | + if (!isset($headers[$h[0]])) { |
|
| 174 | + $headers[$h[0]] = trim($h[1]); |
|
| 175 | + } elseif (is_array($headers[$h[0]])) { |
|
| 176 | 176 | $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); |
| 177 | - } |
|
| 178 | - else { |
|
| 177 | + } else { |
|
| 179 | 178 | $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); |
| 180 | 179 | } |
| 181 | 180 | $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]); |
|
| 181 | + } else { |
|
| 182 | + if (substr($h[0], 0, 1) == "\t") { |
|
| 183 | + $headers[$key] .= "\r\n\t".trim($h[0]); |
|
| 184 | + } elseif (!$key) { |
|
| 185 | + $headers[0] = trim($h[0]); |
|
| 186 | + } |
|
| 188 | 187 | } |
| 189 | 188 | } |
| 190 | 189 | return $headers; |