mirror of
https://github.com/Thavarshan/fetch-php.git
synced 2025-01-16 22:28:15 +01:00
Refactor fetch.php and FetchTest.php files
This commit is contained in:
parent
55db58710a
commit
05bb7db8f5
@ -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());
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
use function Fetch\Http\fetch;
|
||||
|
||||
use Fetch\Http\Response;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
Loading…
x
Reference in New Issue
Block a user