Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Psr18Client.php

class Psr18Client

A generic PSR-18 and PSR-17 implementation.

You can create this class with concrete client and factory instances or let it use discovery to find suitable implementations as needed.

@author Nicolas Grekas <p@tchwork.com>

Hierarchy

  • class \Http\Discovery\Psr17Factory implements \Psr\Http\Message\RequestFactoryInterface, \Psr\Http\Message\ResponseFactoryInterface, \Psr\Http\Message\ServerRequestFactoryInterface, \Psr\Http\Message\StreamFactoryInterface, \Psr\Http\Message\UploadedFileFactoryInterface, \Psr\Http\Message\UriFactoryInterface
    • class \Http\Discovery\Psr18Client extends \Http\Discovery\Psr17Factory implements \Psr\Http\Client\ClientInterface

Expanded class hierarchy of Psr18Client

File

vendor/php-http/discovery/src/Psr18Client.php, line 23

Namespace

Http\Discovery
View source
class Psr18Client extends Psr17Factory implements ClientInterface {
    private $client;
    public function __construct(?ClientInterface $client = null, ?RequestFactoryInterface $requestFactory = null, ?ResponseFactoryInterface $responseFactory = null, ?ServerRequestFactoryInterface $serverRequestFactory = null, ?StreamFactoryInterface $streamFactory = null, ?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();
    }
    public function sendRequest(RequestInterface $request) : ResponseInterface {
        return $this->client
            ->sendRequest($request);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
Psr17Factory::$requestFactory private property
Psr17Factory::$responseFactory private property
Psr17Factory::$serverRequestFactory private property
Psr17Factory::$streamFactory private property
Psr17Factory::$uploadedFileFactory private property
Psr17Factory::$uriFactory private property
Psr17Factory::buildServerRequestFromGlobals private function
Psr17Factory::buildUriFromGlobals private function
Psr17Factory::createRequest public function Overrides RequestFactoryInterface::createRequest
Psr17Factory::createResponse public function Create a new response. Overrides ResponseFactoryInterface::createResponse
Psr17Factory::createServerRequest public function Overrides ServerRequestFactoryInterface::createServerRequest
Psr17Factory::createServerRequestFromGlobals public function
Psr17Factory::createStream public function Create a new stream from a string. Overrides StreamFactoryInterface::createStream
Psr17Factory::createStreamFromFile public function Create a stream from an existing file. Overrides StreamFactoryInterface::createStreamFromFile
Psr17Factory::createStreamFromResource public function Overrides StreamFactoryInterface::createStreamFromResource
Psr17Factory::createUploadedFile public function Create a new uploaded file. Overrides UploadedFileFactoryInterface::createUploadedFile
Psr17Factory::createUploadedFileFromSpec private function Create and return an UploadedFile instance from a $_FILES specification.
Psr17Factory::createUri public function Create a new URI. Overrides UriFactoryInterface::createUri
Psr17Factory::createUriFromGlobals public function
Psr17Factory::normalizeFiles private function
Psr17Factory::setFactory private function
Psr18Client::$client private property
Psr18Client::sendRequest public function Sends a PSR-7 request and returns a PSR-7 response. Overrides ClientInterface::sendRequest
Psr18Client::__construct public function Overrides Psr17Factory::__construct

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal