Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusa87 committed Dec 15, 2024
1 parent 06cd4d7 commit 80355d5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.2-cli
FROM php:8.3-cli
RUN apt-get update && apt-get install -y git unzip && rm -Rf /var/lib/apt/lists/*

COPY --from=composer /usr/bin/composer /usr/bin/composer
Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"minimum-stability": "stable",
"require": {
"php": ">=8.2",
"php-http/discovery": "^1.0",
"php-http/discovery": "^1.20",
"psr/http-client": "^1.0",
"psr/http-client-implementation": "*",
"psr/log": "^1.1",
"symfony/framework-bundle": "^6.4|^7.0",
"symfony/http-client": "^7.0",
"symfony/http-client": "^7.2",
"symfony/http-kernel": "^6.4|^7.0",
"typesense/typesense-php": "^4.9"
},
Expand All @@ -24,6 +25,9 @@
"symfony/phpunit-bridge": "^7.0",
"symfony/yaml": "^7.0"
},
"conflict": {
"php-http/httplug": "<1.5"
},
"config": {
"sort-packages": true,
"allow-plugins": {
Expand Down
27 changes: 17 additions & 10 deletions src/Client/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@

namespace Biblioteca\TypesenseBundle\Client;

use Http\Discovery\Psr18ClientDiscovery;
use Psr\Http\Client\ClientInterface as HttpClient;
use Typesense\Client;
use Typesense\Exceptions\ConfigError;

class ClientFactory
readonly class ClientFactory
{
/**
* @param array<string, mixed> $defaultConfig
*/
public function __construct(
private readonly string $uri,
private string $uri,
#[\SensitiveParameter]
private readonly string $apiKey,
private readonly ?\Psr\Http\Client\ClientInterface $client = null,
private readonly int $connectionTimeoutSeconds = 5,
private readonly array $defaultConfig = [],
private string $apiKey,
private ?HttpClient $client,
private int $connectionTimeoutSeconds = 5,
private array $defaultConfig = [],
) {
}

Expand All @@ -43,14 +45,19 @@ private function getConfiguration(): array
'protocol' => $urlParsed['scheme'],
],
],
'client' => $this->getClient(),
'api_key' => $this->apiKey,
'connection_timeout_seconds' => $this->connectionTimeoutSeconds,
];

if ($this->client) {
$config['client'] = $this->client;
}

return array_merge($this->defaultConfig, $config);
}

/**
* @return HttpClient
*/
public function getClient(): HttpClient
{
return $this->client ?? (new Psr18ClientDiscovery())->find();
}
}

0 comments on commit 80355d5

Please sign in to comment.