class HttplugFactory {}

In this article

This class has been deprecated since since version 1.8, use Psr17Factory instead. since version 1.8, use Psr17Factory instead

Methods

NameDescription
HttplugFactory::createRequest
HttplugFactory::createResponse
HttplugFactory::createStream
HttplugFactory::createUri

Source

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);
    }
}

User Contributed Notes

You must log in before being able to contribute a note or feedback.