2declare(strict_types=1);
6use Psr\Http\Message\StreamInterface;
32 if (!is_string($string)) {
33 throw new \InvalidArgumentException(
'The argument $string must be of type string but was "' . gettype($string) .
'"');
36 $stream =
new Stream(fopen(
'php://memory',
'rw'));
37 $stream->write($string);
54 if (!is_resource($resource)) {
55 throw new \InvalidArgumentException(
'The argument $resource must be of type resource but was "' . gettype($resource) .
'"');
58 return new Stream($resource);
71 $resource = $stream->detach();
An exception for terminatinating execution or to throw for unit testing.
static ofPsr7Stream(StreamInterface $stream)
Create a FileStream from a Psr7 compliant stream.
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
static ofString($string)
Creates a new stream with an initial value.