CoreFiles by mySites.guru
HttplugFactory.php42 lines, 1,228 bytes, from Joomla_4.2.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 4.2.0-alpha1
md5
5b10567df7ce96fb35e54275f8c9b8dd
sha1
8522265ad9f6ad631916ee219792998d5f1b849b
sha256
5585e065b437cbeb09b384b7be397d0d7cace24b182b0dd0d592774c6889bf84
<?php

declare(strict_types=1);

namespace Nyholm\Psr7\Factory;

use Http\Message\{MessageFactory, StreamFactory, UriFactory};
use Nyholm\Psr7\{Request, Response, Stream, Uri};
use Psr\Http\Message\UriInterface;

/**
 * @author Tobias Nyholm <[email protected]>
 * @author Martijn van der Ven <[email protected]>
 *
 * @final This class should never be extended. See https://github.com/Nyholm/psr7/blob/master/doc/final.md
 */
class HttplugFactory implements MessageFactory, StreamFactory, UriFactory
{
    public function createRequest($method, $uri, array $headers = [], $body = null, $protocolVersion = '1.1')
    {
        return new Request($method, $uri, $headers, $body, $protocolVersion);
    }

    public function createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $version = '1.1')
    {
        return new Response((int) $statusCode, $headers, $body, $version, $reasonPhrase);
    }

    public function createStream($body = null)
    {
        return Stream::create($body ?? '');
    }

    public function createUri($uri = ''): UriInterface
    {
        if ($uri instanceof UriInterface) {
            return $uri;
        }

        return new Uri($uri);
    }
}

The same content is in 46 releases, Joomla 4.0.0-rc1 to 4.2.0-alpha2. See them all, or every version of this file.