WordPress\AiClientDependencies\Nyholm\Psr7\Factory

HttplugFactory{}WP 1.0└─ MessageFactory, StreamFactory, UriFactory

Deprecated since 1.8. It is no longer supported and may be removed in future releases. Use Psr17Factory instead.

No Hooks.

Usage

$HttplugFactory = new HttplugFactory();
// use class methods

Methods

  1. public createRequest($method, $uri, array $headers = [], $body = null, $protocolVersion = '1.1')
  2. public createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $version = '1.1')
  3. public createStream($body = null)
  4. public createUri($uri = '')

Changelog

Deprecated since version 1.8, use Psr17Factory instead

HttplugFactory{} code WP 7.0.2

class HttplugFactory implements MessageFactory, StreamFactory, UriFactory
{
    public function createRequest($method, $uri, array $headers = [], $body = null, $protocolVersion = '1.1'): RequestInterface
    {
        return new Request($method, $uri, $headers, $body, $protocolVersion);
    }
    public function createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $version = '1.1'): ResponseInterface
    {
        return new Response((int) $statusCode, $headers, $body, $version, $reasonPhrase);
    }
    public function createStream($body = null): StreamInterface
    {
        return Stream::create($body ?? '');
    }
    public function createUri($uri = ''): UriInterface
    {
        if ($uri instanceof UriInterface) {
            return $uri;
        }
        return new Uri($uri);
    }
}