StreamFactory
in package
implements
StreamFactoryInterface
PSR-17 StreamFactory implementation to create PSR-7 Stream objects
Any construction arguments introduced later SHOULD be optional.
Interfaces, Classes, Traits and Enums
- StreamFactoryInterface
Table of Contents
- createStream() : StreamInterface
- Create a new stream from a string.
- createStreamFromFile() : StreamInterface
- Create a stream from an existing file.
- createStreamFromResource() : StreamInterface
- Create a new stream from an existing resource.
Methods
createStream()
Create a new stream from a string.
public
createStream([string $content = '' ]) : StreamInterface
The stream SHOULD be created with a temporary resource.
Parameters
- $content : string = ''
-
String content with which to populate the stream.
Return values
StreamInterface —createStreamFromFile()
Create a stream from an existing file.
public
createStreamFromFile(string $filename[, string $mode = 'r' ]) : StreamInterface
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
- $filename : string
-
Filename or stream URI to use as basis of stream.
- $mode : string = 'r'
-
Mode with which to open the underlying filename/stream.
Tags
Return values
StreamInterface —createStreamFromResource()
Create a new stream from an existing resource.
public
createStreamFromResource(resource $resource) : StreamInterface
The stream MUST be readable and may be writable.
Parameters
- $resource : resource
-
PHP resource to use as basis of stream.