diff --git a/src/Client.php b/src/Client.php index 94769c0..892e281 100644 --- a/src/Client.php +++ b/src/Client.php @@ -4,18 +4,22 @@ namespace Bunny\Storage; +use GuzzleHttp\Client as HttpClient; +use GuzzleHttp\Promise\Utils as PromiseUtils; +use Psr\Http\Message\ResponseInterface; + class Client { private string $apiAccessKey; private string $storageZoneName; private string $baseUrl; - private \GuzzleHttp\Client $httpClient; + private HttpClient $httpClient; public function __construct( string $apiKey, string $storageZoneName, string $storageZoneRegion = Region::FALKENSTEIN, - ?\GuzzleHttp\Client $httpClient = null + ?HttpClient $httpClient = null ) { if (!isset(Region::LIST[$storageZoneRegion])) { throw new InvalidRegionException(); @@ -25,7 +29,7 @@ public function __construct( $this->storageZoneName = $storageZoneName; $this->baseUrl = Region::getBaseUrl($storageZoneRegion); - $this->httpClient = $httpClient ?? new \GuzzleHttp\Client([ + $this->httpClient = $httpClient ?? new HttpClient([ 'allow_redirects' => false, 'http_errors' => false, 'base_uri' => $this->baseUrl, @@ -259,10 +263,10 @@ public function deleteMultiple(array $to_delete): array $requests[$path] = $this->httpClient->requestAsync('DELETE', $this->normalizePath($path, $isDirectory)); } - $results = \GuzzleHttp\Promise\Utils::unwrap($requests); + $results = PromiseUtils::unwrap($requests); $errors = []; - /** @var \Psr\Http\Message\ResponseInterface $response */ + /** @var ResponseInterface $response */ foreach ($results as $path => $response) { if (200 !== $response->getStatusCode()) { $data = json_decode($response->getBody()->getContents(), true);