Refactor fetch.php and FetchTest.php files

This commit is contained in:
Jerome Thayananthajothy 2024-09-30 19:33:44 +01:00
parent 55db58710a
commit 05bb7db8f5
2 changed files with 3 additions and 6 deletions

View File

@ -1,9 +1,8 @@
<?php
namespace Fetch\Http;
use Fetch\Http\ClientHandler;
use Fetch\Http\Response;
use GuzzleHttp\Exception\RequestException;
use Throwable;
if (! function_exists('fetch')) {
/**
@ -40,7 +39,7 @@ if (! function_exists('fetch')) {
// Synchronous request handling
try {
return ClientHandler::handle($options['method'], $url, $options);
} catch (Throwable $e) {
} catch (\Throwable $e) {
// Handle exceptions and return the response
if ($e instanceof RequestException && $e->hasResponse()) {
return Response::createFromBase($e->getResponse());

View File

@ -1,7 +1,5 @@
<?php
use function Fetch\Http\fetch;
use Fetch\Http\Response;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;