Skip to content

Commit

Permalink
Merge pull request #266 from php-http/psr17-http-client
Browse files Browse the repository at this point in the history
Forward factories implemented by PSR-18 clients if any
  • Loading branch information
dbu authored Apr 22, 2024
2 parents 0700efd + f1bb03a commit ed16f52
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Psr18Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public function __construct(
?UploadedFileFactoryInterface $uploadedFileFactory = null,
?UriFactoryInterface $uriFactory = null
) {
$requestFactory ?? $requestFactory = $client instanceof RequestFactoryInterface ? $client : null;
$responseFactory ?? $responseFactory = $client instanceof ResponseFactoryInterface ? $client : null;
$serverRequestFactory ?? $serverRequestFactory = $client instanceof ServerRequestFactoryInterface ? $client : null;
$streamFactory ?? $streamFactory = $client instanceof StreamFactoryInterface ? $client : null;
$uploadedFileFactory ?? $uploadedFileFactory = $client instanceof UploadedFileFactoryInterface ? $client : null;
$uriFactory ?? $uriFactory = $client instanceof UriFactoryInterface ? $client : null;

parent::__construct($requestFactory, $responseFactory, $serverRequestFactory, $streamFactory, $uploadedFileFactory, $uriFactory);

$this->client = $client ?? Psr18ClientDiscovery::find();
Expand Down

0 comments on commit ed16f52

Please sign in to comment.