Flow PHP

RangeSourceStream implements SourceStream

Read onlyYes
FinalYes

Reads go through the inner read(), so a remote stream fetches only the window.

Interfaces

SourceStream

Methods

__construct()  : mixed
close()  : void
content()  : string
end()  : int
First byte past the window in the inner stream: start() + size().
isOpen()  : bool
iterate()  : Generator<string|int, string>
path()  : Path
read()  : string
readLines()  : Generator<string|int, string>
Yields the stream's lines with the separator stripped: a 0-byte stream yields nothing, a separator that ends the stream opens no further line, and every other empty line is yielded as ''. The separator is matched byte for byte; no "\r" is stripped. "x\ny\n" -> ["x","y"], "x\n\ny" -> ["x","","y"], "x\n\n" -> ["x",""], "x\r\ny" -> ["x\r","y"], "" -> [].
size()  : null|int
start()  : int<0, max>
First byte of the window in the inner stream.
stream()  : SourceStream
The stream the window is cut from.

Methods

__construct()

public __construct(SourceStream $stream, int $start, int $end) : mixed
Parameters
$stream : SourceStream
$start : int

first byte of the window

$end : int

first byte past the window

end()

First byte past the window in the inner stream: start() + size().

public end() : int
Return values
int

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

relative to the window's start; negative counts back from the window's end

Return values
string

readLines()

Yields the stream's lines with the separator stripped: a 0-byte stream yields nothing, a separator that ends the stream opens no further line, and every other empty line is yielded as ''. The separator is matched byte for byte; no "\r" is stripped. "x\ny\n" -> ["x","y"], "x\n\ny" -> ["x","","y"], "x\n\n" -> ["x",""], "x\r\ny" -> ["x\r","y"], "" -> [].

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

multi-byte included

$length : int|null = null

bytes read per step - a read-chunk hint, never a cap on line length; null lets the implementation choose

Return values
Generator<string|int, string>

size()

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

The size of the stream in bytes

start()

First byte of the window in the inner stream.

public start() : int<0, max>
Return values
int<0, max>
On this page

Search results