Skip to content

Commit b4243b2

Browse files
committed
feat: update package to match new docs
1 parent 5e7d7a6 commit b4243b2

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

src/Fetch.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -456,23 +456,3 @@ public static function buildHTTPCurlQuery(array $data, $parent = false): array
456456
return $result;
457457
}
458458
}
459-
460-
/**
461-
* Shortcut method for making network requests.
462-
*
463-
* @param array|string $options The url or request to hit.
464-
* @throws \Exception
465-
*/
466-
function fetch($options, $params = [])
467-
{
468-
if (is_string($options)) {
469-
$options = ["url" => $options];
470-
471-
if (count($params) > 0) {
472-
$options["method"] = Fetch::POST;
473-
$options["data"] = $params;
474-
}
475-
}
476-
477-
return Fetch::request($options);
478-
}

src/functions.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
<?php
22

3-
use function Leaf\fetch as LeafFetch;
3+
use Leaf\Fetch;
44

55
if (!function_exists('fetch')) {
66
/**
77
* Shortcut method for making network requests.
88
*
9-
* @param array|string $options The url or request to hit.
10-
* @throws Exception
9+
* @param array|string $data The url or request to hit.
10+
* @throws \Exception
1111
*/
12-
function fetch($options, $params = [])
12+
function fetch($data = null)
1313
{
14-
return LeafFetch($options, $params);
14+
if (is_string($data)) {
15+
$data = ['url' => $data];
16+
}
17+
18+
if (!$data) {
19+
return new Fetch;
20+
}
21+
22+
return Fetch::request($data);
1523
}
1624
}

0 commit comments

Comments
 (0)