for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace HttpSoft\Message;
use InvalidArgumentException;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\StreamInterface;
use function is_resource;
final class StreamFactory implements StreamFactoryInterface
{
/**
* {@inheritdoc}
*/
public function createStream(string $content = ''): StreamInterface
$stream = new Stream();
$stream->write($content);
$stream->rewind();
return $stream;
}
public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface
return new Stream($filename, $mode);
*
* @psalm-suppress DocblockTypeContradiction
public function createStreamFromResource($resource): StreamInterface
if (!is_resource($resource)) {
throw new InvalidArgumentException('Invalid stream provided. It must be a stream resource.');
return new Stream($resource);