Skip to content

Commit

Permalink
added options to fetch function
Browse files Browse the repository at this point in the history
  • Loading branch information
tombroucke committed Nov 2, 2023
1 parent b8da0f0 commit 7ceb385
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ function timestamp(): string
* var_dump($info['http_code'], $result);
* ```
*/
function fetch(string $url, string $method = 'get', array $headers = [], ?string $body = null, ?array &$info = null, bool $nothrow = false): string
function fetch(string $url, string $method = 'get', array $headers = [], ?string $body = null, ?array &$info = null, bool $nothrow = false, array $options = []): string
{
$url = parse($url);
if (strtolower($method) === 'get') {
Expand All @@ -950,5 +950,8 @@ function fetch(string $url, string $method = 'get', array $headers = [], ?string
if ($body !== null) {
$http = $http->body($body);
}
foreach($options as $key => $value) {
$http = $http->setopt($key, $value);
}
return $http->send($info);
}

0 comments on commit 7ceb385

Please sign in to comment.