From 9da75ce80588c294c14ada25b681d294f537a478 Mon Sep 17 00:00:00 2001 From: Art4 Date: Fri, 24 Feb 2023 11:04:41 +0100 Subject: [PATCH] Replace cache/void-adapter with NullCacheItemPool --- composer.json | 1 - src/Client.php | 13 ++----------- tests/Integration/ClientTest.php | 5 +++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index d6a637b..42af148 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,6 @@ "require": { "php": "^8.0", "art4/json-api-client": "^1.0", - "cache/void-adapter": "^1.1", "guzzlehttp/guzzle": "^7.2", "psr/cache": "^2.0 || ^3.0", "psr/http-client": "^1.0", diff --git a/src/Client.php b/src/Client.php index fd6870a..ba9f59e 100644 --- a/src/Client.php +++ b/src/Client.php @@ -23,7 +23,6 @@ use Art4\JsonApiClient\Accessable; use Art4\JsonApiClient\Helper\Parser as JsonApiParser; -use Cache\Adapter\Void\VoidCachePool; use DateInterval; use DateTimeImmutable; use Exception; @@ -43,6 +42,7 @@ use Throwable; use Youthweb\Api\Authentication\Authenticator; use Youthweb\Api\Authentication\NativeAuthenticator; +use Youthweb\Api\Cache\NullCacheItemPool; use Youthweb\Api\Exception\ErrorResponseException; use Youthweb\Api\Exception\UnauthorizedException; use Youthweb\Api\Resource\ResourceInterface; @@ -198,7 +198,7 @@ public function __construct(array $options = [], array $collaborators = []) $this->oauth2Provider = $collaborators['oauth2_provider']; if (empty($collaborators['cache_provider'])) { - $collaborators['cache_provider'] = new VoidCachePool(); + $collaborators['cache_provider'] = new NullCacheItemPool(); } $this->cacheProvider = $collaborators['cache_provider']; @@ -417,15 +417,6 @@ public function postUnauthorized(string $path, array $data = []): Accessable return $this->runRequest($request); } - /** - * destructor - **/ - public function __destruct() - { - // Save deferred items - $this->cacheProvider->commit(); - } - /** * Returns the Url * diff --git a/tests/Integration/ClientTest.php b/tests/Integration/ClientTest.php index 2313103..e83fd39 100644 --- a/tests/Integration/ClientTest.php +++ b/tests/Integration/ClientTest.php @@ -22,16 +22,17 @@ namespace Youthweb\Api\Tests\Integration; use Youthweb\Api\Client; +use Youthweb\Api\ClientInterface; class ClientTest extends \PHPUnit\Framework\TestCase { /** * @test */ - public function testCreateClientWithoutParameters(): void + public function testClientImplementsClientInterface(): void { $client = new Client(); - $this->assertInstanceOf('Youthweb\Api\ClientInterface', $client); + $this->assertInstanceOf(ClientInterface::class, $client); } }