Documentation

StreamFactoryInterface

Table of Contents

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

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
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.

Return values
StreamInterface

        
On this page

Search results