Skip to content

Commit b460d30

Browse files
committed
Update PSR Client Discovery
1 parent a43b3a1 commit b460d30

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/ApiCall.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Exception;
66
use Http\Client\Exception as HttpClientException;
77
use Http\Client\Exception\HttpException;
8-
use Http\Client\HttpClient;
8+
use Psr\Http\Client\ClientInterface;
99
use Psr\Http\Message\StreamInterface;
1010
use Psr\Log\LoggerInterface;
1111
use Typesense\Exceptions\HTTPStatus0Error;
@@ -33,9 +33,9 @@ class ApiCall
3333
private const API_KEY_HEADER_NAME = 'X-TYPESENSE-API-KEY';
3434

3535
/**
36-
* @var HttpClient
36+
* @var ClientInterface
3737
*/
38-
private HttpClient $client;
38+
private ClientInterface $client;
3939

4040
/**
4141
* @var Configuration

src/Lib/Configuration.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace Typesense\Lib;
44

55
use Http\Client\Common\HttpMethodsClient;
6-
use Http\Client\HttpClient;
7-
use Http\Discovery\HttpClientDiscovery;
8-
use Http\Discovery\MessageFactoryDiscovery;
6+
use Http\Discovery\Psr17FactoryDiscovery;
7+
use Http\Discovery\Psr18ClientDiscovery;
98
use Monolog\Handler\StreamHandler;
109
use Monolog\Logger;
10+
use Psr\Http\Client\ClientInterface;
1111
use Psr\Log\LoggerInterface;
1212
use Typesense\Exceptions\ConfigError;
1313

@@ -57,9 +57,9 @@ class Configuration
5757
private LoggerInterface $logger;
5858

5959
/**
60-
* @var null|HttpClient
60+
* @var null|ClientInterface
6161
*/
62-
private ?HttpClient $client = null;
62+
private ?ClientInterface $client = null;
6363

6464
/**
6565
* @var int
@@ -104,7 +104,7 @@ public function __construct(array $config)
104104
$this->logger = new Logger('typesense');
105105
$this->logger->pushHandler(new StreamHandler('php://stdout', $this->logLevel));
106106

107-
if (true === \array_key_exists('client', $config) && $config['client'] instanceof HttpClient) {
107+
if (true === \array_key_exists('client', $config) && $config['client'] instanceof ClientInterface) {
108108
$this->client = $config['client'];
109109
}
110110
}
@@ -213,13 +213,13 @@ public function getLogger(): LoggerInterface
213213
}
214214

215215
/**
216-
* @return HttpClient
216+
* @return ClientInterface
217217
*/
218-
public function getClient(): HttpClient
218+
public function getClient(): ClientInterface
219219
{
220220
return new HttpMethodsClient(
221-
$this->client ?? HttpClientDiscovery::find(),
222-
MessageFactoryDiscovery::find()
221+
$this->client ?? Psr18ClientDiscovery::find(),
222+
Psr17FactoryDiscovery::findRequestFactory()
223223
);
224224
}
225225
}

0 commit comments

Comments
 (0)