@@ -87,7 +87,7 @@ |
||
87 | 87 | */ |
88 | 88 | public static function insensitiveString(string $string, string $value): bool |
89 | 89 | { |
90 | - return (bool)preg_match_all('/' . $value . '/i', $string); |
|
90 | + return (bool) preg_match_all('/' . $value . '/i', $string); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | } |
94 | 94 | \ No newline at end of file |
@@ -54,7 +54,9 @@ |
||
54 | 54 | */ |
55 | 55 | public function getInfoFromCurl(): CurlInfo|false |
56 | 56 | { |
57 | - if (empty($this->getCurlHandle())) return false; |
|
57 | + if (empty($this->getCurlHandle())) { |
|
58 | + return false; |
|
59 | + } |
|
58 | 60 | return new CurlInfo(curl_getinfo($this->curlHandle)); |
59 | 61 | } |
60 | 62 |
@@ -99,9 +99,11 @@ discard block |
||
99 | 99 | public function request(string $method, string $uri, array|HttpOptions $options = []): HttpResponse |
100 | 100 | { |
101 | 101 | $CurlHandle = $this->create_curl_handler($method, $uri, $options); |
102 | - if (!$CurlHandle) throw new RuntimeException( |
|
102 | + if (!$CurlHandle) { |
|
103 | + throw new RuntimeException( |
|
103 | 104 | 'An error occurred while creating the curl handler' |
104 | 105 | ); |
106 | + } |
|
105 | 107 | |
106 | 108 | $result = new HttpResponse(); |
107 | 109 | $result->setCurlHandle($CurlHandle); |
@@ -145,9 +147,11 @@ discard block |
||
145 | 147 | $request['uri'], |
146 | 148 | $request['options'] ?? [] |
147 | 149 | ); |
148 | - if (!$CurlHandle) throw new RuntimeException( |
|
150 | + if (!$CurlHandle) { |
|
151 | + throw new RuntimeException( |
|
149 | 152 | 'An error occurred while creating the curl handler' |
150 | 153 | ); |
154 | + } |
|
151 | 155 | $handlers[] = $CurlHandle; |
152 | 156 | curl_multi_add_handle($multi_handler, $CurlHandle); |
153 | 157 | |
@@ -207,14 +211,18 @@ discard block |
||
207 | 211 | private function create_curl_handler(?string $method, string $uri, array|HttpOptions $options = []): false|CurlHandle |
208 | 212 | { |
209 | 213 | $handler = curl_init(); |
210 | - if (is_resource($handler) || !$handler) return false; |
|
214 | + if (is_resource($handler) || !$handler) { |
|
215 | + return false; |
|
216 | + } |
|
211 | 217 | |
212 | 218 | if (gettype($options) === 'array') { |
213 | 219 | $options = new HttpOptions($options); |
214 | 220 | } |
215 | 221 | |
216 | 222 | if (count($options->getQuery()) > 0) { |
217 | - if (!str_contains($uri, '?')) $uri .= '?'; |
|
223 | + if (!str_contains($uri, '?')) { |
|
224 | + $uri .= '?'; |
|
225 | + } |
|
218 | 226 | $uri .= $options->getQueryString(); |
219 | 227 | } |
220 | 228 | |
@@ -413,7 +421,9 @@ discard block |
||
413 | 421 | |
414 | 422 | $headers = []; |
415 | 423 | foreach ($options->getHeader() as $header => $value) { |
416 | - if (Utils::insensitiveString($header, 'content-type')) continue; |
|
424 | + if (Utils::insensitiveString($header, 'content-type')) { |
|
425 | + continue; |
|
426 | + } |
|
417 | 427 | $headers[] = $header . ': ' . $value; |
418 | 428 | } |
419 | 429 | $headers[] = 'Content-Type: multipart/form-data'; |