StreamFactory implements StreamFactoryInterface

Internal

Note that this is not public API, use PSR-17 interfaces instead.

Table of Contents

Interfaces

StreamFactoryInterface

Methods

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
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 $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
throws
RuntimeException

If the file cannot be opened.

throws
InvalidArgumentException

If the mode is invalid.

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.

Tags
throws
InvalidArgumentException
Return values
StreamInterface

        
On this page

Search results