-
-
Notifications
You must be signed in to change notification settings - Fork 0
StreamFactory
Class StreamFactory.
Decorates a PSR-17 StreamFactoryInterface to provide additional functionality for creating payload streams. Implements both standard PSR-17 stream creation methods and convenient payload-aware stream generation.
- Full name:
\FastForward\Http\Message\Factory\StreamFactory - This class is marked as final and can't be subclassed
- This class implements:
\FastForward\Http\Message\Factory\StreamFactoryInterface - This class is a Final class
Constructs the StreamFactory instance.
public __construct(\Psr\Http\Message\StreamFactoryInterface $streamFactory): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$streamFactory |
\Psr\Http\Message\StreamFactoryInterface | the underlying PSR-17 stream factory implementation |
Creates a new stream containing the provided string content.
public createStream(string $content = ''): \Psr\Http\Message\StreamInterfaceParameters:
| Parameter | Type | Description |
|---|---|---|
$content |
string | the string content for the stream |
Return Value:
the generated stream
Creates a new stream from the specified file.
public createStreamFromFile(string $filename, string $mode = 'r'): \Psr\Http\Message\StreamInterfaceThe file is opened with the given mode, and a stream is returned.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$filename |
string | the path to the file to open as a stream |
$mode |
string | The file open mode. Defaults to 'r' (read mode). |
Return Value:
the generated stream
Creates a new stream from the provided PHP resource.
public createStreamFromResource(resource $resource): \Psr\Http\Message\StreamInterfaceParameters:
| Parameter | Type | Description |
|---|---|---|
$resource |
resource | the PHP resource to wrap as a stream |
Return Value:
the generated stream
Creates a new stream containing the JSON-encoded representation of the provided payload.
public createStreamFromPayload(array $payload): \FastForward\Http\Message\PayloadStreamInterfaceThe returned stream implements PayloadStreamInterface and contains the encoded payload.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$payload |
array | the payload to encode as JSON |
Return Value:
the generated payload stream