@@ -40,8 +40,12 @@ discard block |
||
| 40 | 40 | public function __construct(string $url, array $data = [], array $headers = []) |
| 41 | 41 | { |
| 42 | 42 | $this->setURL($url); |
| 43 | - foreach ($data as $name => $value) $this->addDataParam($name, $value); |
|
| 44 | - foreach ($headers as $name => $value) $this->addHeader($name, $value); |
|
| 43 | + foreach ($data as $name => $value) { |
|
| 44 | + $this->addDataParam($name, $value); |
|
| 45 | + } |
|
| 46 | + foreach ($headers as $name => $value) { |
|
| 47 | + $this->addHeader($name, $value); |
|
| 48 | + } |
|
| 45 | 49 | } |
| 46 | 50 | |
| 47 | 51 | /** |
@@ -100,7 +104,9 @@ discard block |
||
| 100 | 104 | |
| 101 | 105 | public function removeDataParam(string $name): Curl |
| 102 | 106 | { |
| 103 | - if (array_key_exists($name, $this->_data)) unset($this->_data[$name]); |
|
| 107 | + if (array_key_exists($name, $this->_data)) { |
|
| 108 | + unset($this->_data[$name]); |
|
| 109 | + } |
|
| 104 | 110 | return $this; |
| 105 | 111 | } |
| 106 | 112 | |
@@ -129,7 +135,9 @@ discard block |
||
| 129 | 135 | */ |
| 130 | 136 | public function removeHeader(string $name): Curl |
| 131 | 137 | { |
| 132 | - if (array_key_exists($name, $this->_headers)) unset($this->_headers[$name]); |
|
| 138 | + if (array_key_exists($name, $this->_headers)) { |
|
| 139 | + unset($this->_headers[$name]); |
|
| 140 | + } |
|
| 133 | 141 | return $this; |
| 134 | 142 | } |
| 135 | 143 | |
@@ -173,13 +181,17 @@ discard block |
||
| 173 | 181 | $request_uri = $this->getURL(); |
| 174 | 182 | |
| 175 | 183 | // Headers |
| 176 | - foreach ($this->getHeaders() as $k => $v) $send_headers[] = "{$k}: {$v}"; |
|
| 184 | + foreach ($this->getHeaders() as $k => $v) { |
|
| 185 | + $send_headers[] = "{$k}: {$v}"; |
|
| 186 | + } |
|
| 177 | 187 | |
| 178 | 188 | // Request Data |
| 179 | 189 | switch ($this->getMethod()) { |
| 180 | 190 | case 'GET': |
| 181 | 191 | case 'DELETE': |
| 182 | - foreach ($this->getDataParams() as $name => $value) $request_uri = URL::setGetVar($name, $value, $request_uri); |
|
| 192 | + foreach ($this->getDataParams() as $name => $value) { |
|
| 193 | + $request_uri = URL::setGetVar($name, $value, $request_uri); |
|
| 194 | + } |
|
| 183 | 195 | break; |
| 184 | 196 | |
| 185 | 197 | case 'POST': |
@@ -210,7 +222,9 @@ discard block |
||
| 210 | 222 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
| 211 | 223 | curl_setopt($ch, CURLOPT_AUTOREFERER, true); |
| 212 | 224 | |
| 213 | - if (!empty($send_headers)) curl_setopt($ch, CURLOPT_HTTPHEADER, $send_headers); |
|
| 225 | + if (!empty($send_headers)) { |
|
| 226 | + curl_setopt($ch, CURLOPT_HTTPHEADER, $send_headers); |
|
| 227 | + } |
|
| 214 | 228 | if (!is_null($post_data)) { |
| 215 | 229 | curl_setopt($ch, CURLOPT_POST, 1); |
| 216 | 230 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); |
@@ -220,7 +234,9 @@ discard block |
||
| 220 | 234 | $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 221 | 235 | |
| 222 | 236 | $response = new CurlResponse((int) $http_code, (string) $result); |
| 223 | - if ($this->_enable_cache && isset($cache_key)) self::$_cache[$cache_key] = $response; |
|
| 237 | + if ($this->_enable_cache && isset($cache_key)) { |
|
| 238 | + self::$_cache[$cache_key] = $response; |
|
| 239 | + } |
|
| 224 | 240 | |
| 225 | 241 | return $response; |
| 226 | 242 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace Lifeboat; |
| 4 | 4 | |
| 5 | -require_once __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'functions.php'; |
|
| 5 | +require_once __DIR__.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'functions.php'; |
|
| 6 | 6 | |
| 7 | 7 | use Lifeboat\Exceptions\BadMethodException; |
| 8 | 8 | use Lifeboat\Exceptions\OAuthException; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | public function curl_api(string $url, string $method = 'GET', array $data = [], array $headers = []): CurlResponse |
| 143 | 143 | { |
| 144 | 144 | $uri = URL::is_absolute_url($url) ? $url |
| 145 | - : 'https://' . rtrim($this->getHost(), '/') . '/' . ltrim($url, '/'); |
|
| 145 | + : 'https://'.rtrim($this->getHost(), '/').'/'.ltrim($url, '/'); |
|
| 146 | 146 | |
| 147 | 147 | $curl = new Curl($uri, $data, $headers); |
| 148 | 148 | |
@@ -178,6 +178,6 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | protected function auth_url(string $path): string |
| 180 | 180 | { |
| 181 | - return rtrim($this->_auth_domain, '/') . '/' . ltrim($path, '/'); |
|
| 181 | + return rtrim($this->_auth_domain, '/').'/'.ltrim($path, '/'); |
|
| 182 | 182 | } |
| 183 | 183 | } |