Skip to content

Commit ab3b63a

Browse files
committed
Refactoring http client
1 parent 61b6b9a commit ab3b63a

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

src/Http/Client/HttpClient.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class HttpClient
5353
public function __construct(?string $base_url = null)
5454
{
5555
if (!function_exists('curl_init')) {
56-
throw new BadFunctionCallException('cURL php is require.');
56+
throw new BadFunctionCallException('cURL extension is required.');
5757
}
5858

5959
if (!is_null($base_url)) {
@@ -73,7 +73,7 @@ public function setBaseUrl(string $url): void
7373
}
7474

7575
/**
76-
* Make get requester
76+
* Make GET request
7777
*
7878
* @param string $url
7979
* @param array $data
@@ -97,7 +97,7 @@ public function get(string $url, array $data = []): Response
9797
}
9898

9999
/**
100-
* Reset always connection
100+
* Initialize connection with URL
101101
*
102102
* @param string $url
103103
* @return void
@@ -112,7 +112,7 @@ private function init(string $url): void
112112
}
113113

114114
/**
115-
* Set Curl CURLOPT_RETURNTRANSFER option
115+
* Apply common cURL options
116116
*
117117
* @return void
118118
*/
@@ -161,7 +161,7 @@ private function close(): void
161161
}
162162

163163
/**
164-
* Make post requester
164+
* Make POST request
165165
*
166166
* @param string $url
167167
* @param array $data
@@ -214,7 +214,7 @@ private function addFields(array $data): void
214214
}
215215

216216
/**
217-
* Make put requester
217+
* Make PUT request
218218
*
219219
* @param string $url
220220
* @param array $data
@@ -227,15 +227,15 @@ public function put(string $url, array $data = []): Response
227227
$this->addFields($data);
228228
$this->applyCommonOptions();
229229

230-
curl_setopt($this->ch, CURLOPT_PUT, true);
230+
curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, "PUT");
231231

232232
$content = $this->execute();
233233

234234
return new Response($this->ch, $content);
235235
}
236236

237237
/**
238-
* Make put requester
238+
* Make DELETE request
239239
*
240240
* @param string $url
241241
* @param array $data
@@ -256,7 +256,7 @@ public function delete(string $url, array $data = []): Response
256256
}
257257

258258
/**
259-
* Attach new file
259+
* Attach file(s) to the request
260260
*
261261
* @param string|array $attach
262262
* @return HttpClient
@@ -269,7 +269,7 @@ public function addAttach(string|array $attach): HttpClient
269269
}
270270

271271
/**
272-
* Set the user agent
272+
* Set the User-Agent header
273273
*
274274
* @param string $user_agent
275275
* @return HttpClient
@@ -282,7 +282,7 @@ public function setUserAgent(string $user_agent): HttpClient
282282
}
283283

284284
/**
285-
* Set the json accept prop to format the sent content in json
285+
* Configure client to accept and send JSON data
286286
*
287287
* @return HttpClient
288288
*/
@@ -296,7 +296,7 @@ public function acceptJson(): HttpClient
296296
}
297297

298298
/**
299-
* Add additional header
299+
* Add custom HTTP headers
300300
*
301301
* @param array $headers
302302
* @return HttpClient

0 commit comments

Comments
 (0)