PluginProbe
DecaLog / 4.4.0
DecaLog v4.4.0
3.0.2 3.1.0 3.10.0 3.2.0 3.3.0 3.4.0 3.4.1 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.6.3 3.7.0 3.7.1 3.8.0 3.9.0 3.9.1 4.0.0 4.1.0 4.2.0 4.3.0 4.3.1 4.4.0 4.5.0 All 75 releases
decalog / includes / libraries / http / discovery / Psr18Client.php

Psr18Client.php in DecaLog 4.4.0, at includes/libraries/http/discovery/Psr18Client.php

46 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Http\Discovery;
4
5 use Psr\Http\Client\ClientInterface;
6 use Psr\Http\Message\RequestFactoryInterface;
7 use Psr\Http\Message\RequestInterface;
8 use Psr\Http\Message\ResponseFactoryInterface;
9 use Psr\Http\Message\ResponseInterface;
10 use Psr\Http\Message\ServerRequestFactoryInterface;
11 use Psr\Http\Message\StreamFactoryInterface;
12 use Psr\Http\Message\UploadedFileFactoryInterface;
13 use Psr\Http\Message\UriFactoryInterface;
14
15 /**
16 * A generic PSR-18 and PSR-17 implementation.
17 *
18 * You can create this class with concrete client and factory instances
19 * or let it use discovery to find suitable implementations as needed.
20 *
21 * @author Nicolas Grekas <p@tchwork.com>
22 */
23 class Psr18Client extends Psr17Factory implements ClientInterface
24 {
25 private $client;
26
27 public function __construct(
28 ?ClientInterface $client = null,
29 ?RequestFactoryInterface $requestFactory = null,
30 ?ResponseFactoryInterface $responseFactory = null,
31 ?ServerRequestFactoryInterface $serverRequestFactory = null,
32 ?StreamFactoryInterface $streamFactory = null,
33 ?UploadedFileFactoryInterface $uploadedFileFactory = null,
34 ?UriFactoryInterface $uriFactory = null
35 ) {
36 parent::__construct($requestFactory, $responseFactory, $serverRequestFactory, $streamFactory, $uploadedFileFactory, $uriFactory);
37
38 $this->client = $client ?? Psr18ClientDiscovery::find();
39 }
40
41 public function sendRequest(RequestInterface $request): ResponseInterface
42 {
43 return $this->client->sendRequest($request);
44 }
45 }
46