Class StreamFactory
Factory class for creating stream instances.
Method Summary
-
createStream() public
Create a new stream from a string.
The stream SHOULD be created with a temporary resource.
-
createStreamFromFile() public
Create a stream from an existing file.
The file MUST be opened using the given mode, which may be any mode supported by the
fopenfunction.The
$filenameMAY be any string supported byfopen(). -
createStreamFromResource() public
Create a new stream from an existing resource.
The stream MUST be readable and may be writable.
Method Detail
createStream() ¶ public
createStream(string $content = ''): Stream
Create a new stream from a string.
The stream SHOULD be created with a temporary resource.
Parameters
-
string$content optional String content with which to populate the stream.
Returns
StreamcreateStreamFromFile() ¶ public
createStreamFromFile(string $filename, string $mode = 'r'): Stream
Create a stream from an existing file.
The file MUST be opened using the given mode, which may be any mode
supported by the fopen function.
The $filename MAY be any string supported by fopen().
Parameters
-
string$filename The filename or stream URI to use as basis of stream.
-
string$mode optional The mode with which to open the underlying filename/stream.
Returns
StreamThrows
RuntimeExceptionIf the file cannot be opened.
InvalidArgumentExceptionIf the mode is invalid.
createStreamFromResource() ¶ public
createStreamFromResource(resource $resource): Stream
Create a new stream from an existing resource.
The stream MUST be readable and may be writable.
Parameters
-
resource$resource The PHP resource to use as the basis for the stream.
Returns
Stream