Skip to content

Commit

Permalink
fix psr
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusa87 committed Feb 25, 2025
1 parent 032f3b5 commit 1103959
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Client/ClientSingletonFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Biblioverse\TypesenseBundle\Client;

use Http\Client\Common\HttpMethodsClient;
use Http\Client\Common\HttpMethodsClientInterface;
use Http\Discovery\Psr17FactoryDiscovery;
use Http\Discovery\Psr18ClientDiscovery;
use Psr\Http\Client\ClientInterface as HttpClient;
use Typesense\Client;
Expand Down Expand Up @@ -63,15 +66,14 @@ private function getConfiguration(): array
return array_merge($this->defaultConfig, $config);
}

protected function getClient(): HttpClient
protected function getClient(): HttpMethodsClientInterface
{
$client = $this->httpClient ?? (new Psr18ClientDiscovery())->find();

// Fix upstream bug that calls 'send' instead of 'sendRequest'.
if (!method_exists($client, 'send')) {
return new WrapPSR18WithSendMethod($client);
}

return $client;
return new HttpMethodsClient(
$client,
Psr17FactoryDiscovery::findRequestFactory(),
Psr17FactoryDiscovery::findStreamFactory()
);
}
}

0 comments on commit 1103959

Please sign in to comment.