Flow PHP

MemoryStream implements DestinationStream, SourceStream

FinalYes

Interfaces

DestinationStream
SourceStream

Methods

__construct()  : mixed
__destruct()  : mixed
append()  : DestinationStream
close()  : void
We are not closing memory streams, in order to cleanup memory use rm on Memory Filesystem.
content()  : string
fromResource()  : DestinationStream
isOpen()  : bool
iterate()  : Generator<string|int, string>
path()  : Path
read()  : string
readLines()  : Generator<string|int, string>
size()  : null|int

Methods

__construct()

public __construct(resource $handle, Path $path) : mixed
Parameters
$handle : resource
$path : Path

close()

We are not closing memory streams, in order to cleanup memory use rm on Memory Filesystem.

public close() : void

content()

public content() : string
Return values
string

iterate()

public iterate([int $length = 1 ]) : Generator<string|int, string>
Parameters
$length : int = 1

number of bytes to read from the stream

Return values
Generator<string|int, string>

read()

public read(int $length, int $offset) : string
Parameters
$length : int

number of bytes to read from the stream

$offset : int

The offset where to start reading from the stream. If negative, reading will start from the end of the stream.

Return values
string

readLines()

public readLines([string $separator = " " ][, int|null $length = null ]) : Generator<string|int, string>
Parameters
$separator : string = " "

The line separator, content will be read until the first occurrence of the separator

$length : int|null = null

Number of bytes to read in one step. If the end of the stream or separator is reached before the specified number of bytes are read, the remaining bytes are returned. Otherwise we are reading until the separator is found or end of file is reached. When working with remote streams it might be a good idea to set length to few mb in orders to reduce number of network requests. When no value is provided, filesystems will use a default value, for example NativeLocalFilesystem is going to use 8192 length.

Return values
Generator<string|int, string>

size()

public size() : null|int
Return values
null|int

The size of the stream in bytes


        
On this page

Search results