Korin API

RecordStream
in package
implements IteratorAggregate

FinalYes

A file read one {@see Record} at a time, in memory that does not grow with the file (SPEC section 6, read modes). Records are parsed as {@see Parser} parses the whole file: the same nodes, values and line diagnostics, which each record's document holds. The encoding is detected from the BOM, HEAD.CHAR and the first 64 KB; bytes later in the file that are invalid in it are reported on their line (KV1003), not decoded again.

The version comes from the first HEAD: records before it are read as 5.5.1 (or the version in the options). self::diagnostics() has those of the whole file (encoding, HEAD, TRLR, version), complete once every record was read. A stream is read once.

Tags
implements

Table of Contents

Interfaces

IteratorAggregate

Methods

__construct()  : mixed
diagnostics()  : array<int, Diagnostic>
encoding()  : Encoding
getIterator()  : Generator<int, Record>
hasBom()  : bool
version()  : Version
The version of the records read so far: 5.5.1 (or the one in the options) until HEAD is read.

Methods

__construct()

public __construct(resource $handle[, ReadOptions $options = new ReadOptions() ][, bool $close = false ][, int $chunkSize = 65536 ][, Parser $parser = new Parser() ]) : mixed
Parameters
$handle : resource

read from its current position

$options : ReadOptions = new ReadOptions()
$close : bool = false

whether the stream closes the handle when it ends

$chunkSize : int = 65536
$parser : Parser = new Parser()

diagnostics()

public diagnostics() : array<int, Diagnostic>
Return values
array<int, Diagnostic> —

diagnostics of the whole file: encoding detection, then, once the last record was read, HEAD, TRLR and version (KV1004–KV1008)

version()

The version of the records read so far: 5.5.1 (or the one in the options) until HEAD is read.

public version() : Version
Return values
Version
On this page

Search results