CoreFiles by mySites.guru
StreamFactory.php50 lines, 1,129 bytes, from Joomla_6.2.1-rc1-Release_Candidate-Full_Package.zip
Raw History Compare with 6.2.0-rc2
md5
02c46dae6de4aec7ea5358098110db46
sha1
1ce9f1c4f4f0bb1230225e50b2859b99f656612b
sha256
d19289cc1486851715e8ae4faf8253bae1bb77f3382844991eb6d79eb71360f3
<?php

declare(strict_types=1);

namespace Laminas\Diactoros;

use Override;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\StreamInterface;

use function assert;
use function fopen;
use function fwrite;
use function is_resource;
use function rewind;

class StreamFactory implements StreamFactoryInterface
{
    /**
     * {@inheritDoc}
     */
    #[Override]
    public function createStream(string $content = ''): StreamInterface
    {
        $resource = fopen('php://temp', 'r+');
        assert(is_resource($resource), 'Something is really wrong if PHP failed to open stream in memory');
        fwrite($resource, $content);
        rewind($resource);

        return $this->createStreamFromResource($resource);
    }

    /**
     * {@inheritDoc}
     */
    #[Override]
    public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface
    {
        return new Stream($filename, $mode);
    }

    /**
     * {@inheritDoc}
     */
    #[Override]
    public function createStreamFromResource($resource): StreamInterface
    {
        return new Stream($resource);
    }
}

The same content is in 32 releases, Joomla 6.1.0-alpha2 to 6.3.0-alpha1. See them all, or every version of this file.