-
Notifications
You must be signed in to change notification settings - Fork 51
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
❌ Current Issue: Hardcoded Guzzle
Right now, ApiFactory forces Guzzle usage:
use GuzzleHttp\Client;
public function run(): Client
{
return new Client([...]); // ❌ Forces Guzzle
}
✅ Updated: Use php-http/discovery to Auto-Detect the HTTP Client
Modify ApiFactory to support both Guzzle and Symfony's HTTP client dynamically:
use Http\Discovery\HttpClientDiscovery;
use Http\Discovery\Psr17FactoryDiscovery;
use Psr\Http\Client\ClientInterface;
final class ApiFactory implements ApiFactoryContract
{
protected string $apiKey;
protected string $baseUrl;
protected int $timeout;
public static function build(): self
{
return new self;
}
public function setBaseUri(?string $baseUrl = null): self
{
$this->baseUrl = $baseUrl ?: DefaultConfigs::BASE_URL->value;
return $this;
}
public function setKey(string $apiKey): self
{
$this->apiKey = trim($apiKey);
return $this;
}
public function setTimeout(?int $timeout = null): self
{
$this->timeout = $timeout ?: (int)DefaultConfigs::TIMEOUT->value;
return $this;
}
public function run(): ClientInterface
{
return HttpClientDiscovery::find(); // Auto-detects installed HTTP client (Guzzle or Symfony)
}
}
So the package will automatically work with either Guzzle or Symfony HTTP client!
tomhatzer, hizmarck and IsraelOrtuno
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request