Skip to content

Commit

Permalink
Forward factories implemented by PSR-18 clients if any
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Apr 22, 2024
1 parent 0700efd commit d31b7b0
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 ??= $client instanceof RequestFactoryInterface ? $client : null;
$responseFactory ??= $client instanceof ResponseFactoryInterface ? $client : null;
$serverRequestFactory ??= $client instanceof ServerRequestFactoryInterface ? $client : null;
$streamFactory ??= $client instanceof StreamFactoryInterface ? $client : null;
$uploadedFileFactory ??= $client instanceof UploadedFileFactoryInterface ? $client : null;
$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 d31b7b0

Please sign in to comment.