|
3 | 3 | namespace Typesense\Lib; |
4 | 4 |
|
5 | 5 | 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; |
9 | 8 | use Monolog\Handler\StreamHandler; |
10 | 9 | use Monolog\Logger; |
| 10 | +use Psr\Http\Client\ClientInterface; |
11 | 11 | use Psr\Log\LoggerInterface; |
12 | 12 | use Typesense\Exceptions\ConfigError; |
13 | 13 |
|
@@ -57,9 +57,9 @@ class Configuration |
57 | 57 | private LoggerInterface $logger; |
58 | 58 |
|
59 | 59 | /** |
60 | | - * @var null|HttpClient |
| 60 | + * @var null|ClientInterface |
61 | 61 | */ |
62 | | - private ?HttpClient $client = null; |
| 62 | + private ?ClientInterface $client = null; |
63 | 63 |
|
64 | 64 | /** |
65 | 65 | * @var int |
@@ -104,7 +104,7 @@ public function __construct(array $config) |
104 | 104 | $this->logger = new Logger('typesense'); |
105 | 105 | $this->logger->pushHandler(new StreamHandler('php://stdout', $this->logLevel)); |
106 | 106 |
|
107 | | - if (true === \array_key_exists('client', $config) && $config['client'] instanceof HttpClient) { |
| 107 | + if (true === \array_key_exists('client', $config) && $config['client'] instanceof ClientInterface) { |
108 | 108 | $this->client = $config['client']; |
109 | 109 | } |
110 | 110 | } |
@@ -213,13 +213,13 @@ public function getLogger(): LoggerInterface |
213 | 213 | } |
214 | 214 |
|
215 | 215 | /** |
216 | | - * @return HttpClient |
| 216 | + * @return ClientInterface |
217 | 217 | */ |
218 | | - public function getClient(): HttpClient |
| 218 | + public function getClient(): ClientInterface |
219 | 219 | { |
220 | 220 | return new HttpMethodsClient( |
221 | | - $this->client ?? HttpClientDiscovery::find(), |
222 | | - MessageFactoryDiscovery::find() |
| 221 | + $this->client ?? Psr18ClientDiscovery::find(), |
| 222 | + Psr17FactoryDiscovery::findRequestFactory() |
223 | 223 | ); |
224 | 224 | } |
225 | 225 | } |
0 commit comments