Documentation

StreamFactory
in package
implements StreamFactoryInterface

PSR-17 stream factory class

Tags
category

Pop

author

Nick Sagona, III nick@popphp.org

copyright

Copyright (c) 2009-2026 Nick Sagona, III

license

https://www.popphp.org/license New BSD License

version
6.0.0

Table of Contents

Interfaces

StreamFactoryInterface

Methods

createStream()  : StreamInterface
Create a new stream from a string
createStreamFromFile()  : StreamInterface
Create a new stream from a file path
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 = ''
Return values
StreamInterface

createStreamFromFile()

Create a new stream from a file path

public createStreamFromFile(string $filename[, string $mode = 'r' ]) : StreamInterface

Opens the file directly with the given mode (bypassing Body::setContentFromFile(), which always opens read-only) so the stream honors the mode the caller requested, and throws \RuntimeException on failure per the PSR-17 contract.

Parameters
$filename : string
$mode : string = 'r'
Tags
throws
RuntimeException
Return values
StreamInterface

createStreamFromResource()

Create a new stream from an existing resource

public createStreamFromResource(mixed $resource) : StreamInterface
Parameters
$resource : mixed
Return values
StreamInterface

        
On this page

Search results