Buffer
in package
implements
TabularData
FinalYes
Table of Contents
Interfaces
Constants
- EXCLUDE_HEADER = 2
- INCLUDE_HEADER = 1
Properties
- $formatters : array<string|int, callable(array<string|int, mixed>): array<string|int, mixed>>
- $header : array<int, string>|array{}
- $nullRecord : array<string, null>
- $rows : array<int, array<int, mixed>>
- $sortedHeader : array<int, string>|array{}
- $validators : array<string|int, callable(array<string|int, mixed>): bool>
Methods
- __construct() : mixed
- addFormatter() : self
- Adds a record formatter.
- addValidator() : self
- Adds a record validator.
- delete() : int
- fetchColumn() : Iterator<int, mixed>
- Returns a single column from the next record of the tabular data.
- first() : array<string|int, mixed>
- firstAsObject() : object|null
- firstOffset() : int|null
- from() : self
- Returns a new instance from a tabular data implementing object.
- getHeader() : array<int, string>|array{}
- Returns the header associated with the tabular data.
- getRecords() : Iterator<int, array<string|int, mixed>>
- Returns the tabular data records as an iterator object.
- getRecordsAsObject() : iterator<string|int, T>
- hasHeader() : bool
- insert() : int
- isEmpty() : bool
- last() : array<string|int, mixed>
- lastAsObject() : object|null
- lastOffset() : int|null
- map() : Iterator<string|int, TMap>
- Run a map over each container members.
- nth() : array<string|int, mixed>
- nthAsObject() : object|null
- recordCount() : int
- to() : int
- truncate() : void
- update() : int
- filterInsertRecord() : bool
- filterPredicate() : Predicate
- filterUpdateRecord() : array<string|int, mixed>
- formatInsertRecord() : array<string|int, mixed>
- nthRow() : array<string|int, mixed>
- rowToRecord() : array<string|int, mixed>
- validateRecord() : array<string|int, mixed>
- Validates a record.
Constants
EXCLUDE_HEADER
public
mixed
EXCLUDE_HEADER
= 2
INCLUDE_HEADER
public
mixed
INCLUDE_HEADER
= 1
Properties
$formatters
private
array<string|int, callable(array<string|int, mixed>): array<string|int, mixed>>
$formatters
= []
collection of Closure to format the record before reading.
$header read-only
private
array<int, string>|array{}
$header
$nullRecord read-only
private
array<string, null>
$nullRecord
$rows
private
array<int, array<int, mixed>>
$rows
= []
$sortedHeader read-only
private
array<int, string>|array{}
$sortedHeader
$validators
private
array<string|int, callable(array<string|int, mixed>): bool>
$validators
= []
callable collection to validate the record before insertion.
Methods
__construct()
public
__construct([array<int, string>|array{} $header = [] ]) : mixed
Parameters
- $header : array<int, string>|array{} = []
Tags
addFormatter()
Adds a record formatter.
public
addFormatter(callable(array<string|int, mixed>): array<string|int, mixed> $formatter) : self
Parameters
- $formatter : callable(array<string|int, mixed>): array<string|int, mixed>
Return values
selfaddValidator()
Adds a record validator.
public
addValidator(callable(array<string|int, mixed>): bool $validator, string $name) : self
Parameters
- $validator : callable(array<string|int, mixed>): bool
- $name : string
Return values
selfdelete()
public
delete(Predicate|Closure|callable $where) : int
Parameters
- $where : Predicate|Closure|callable
Tags
Return values
intfetchColumn()
Returns a single column from the next record of the tabular data.
public
fetchColumn([int|string $index = 0 ]) : Iterator<int, mixed>
By default, if no value is supplied the first column is fetched
Parameters
- $index : int|string = 0
-
CSV column index
Return values
Iterator<int, mixed>first()
public
first() : array<string|int, mixed>
Return values
array<string|int, mixed>firstAsObject()
public
firstAsObject(class-string $className[, array<string|int, string> $header = [] ]) : object|null
Parameters
- $className : class-string
- $header : array<string|int, string> = []
Tags
Return values
object|nullfirstOffset()
public
firstOffset() : int|null
Return values
int|nullfrom()
Returns a new instance from a tabular data implementing object.
public
static from(PDOStatement|Result|mysqli_result|SQLite3Result|TabularData|TabularDataProvider $dataStorage[, int $options = self::INCLUDE_HEADER ]) : self
Parameters
- $dataStorage : PDOStatement|Result|mysqli_result|SQLite3Result|TabularData|TabularDataProvider
- $options : int = self::INCLUDE_HEADER
Tags
Return values
selfgetHeader()
Returns the header associated with the tabular data.
public
getHeader() : array<int, string>|array{}
Return values
array<int, string>|array{}getRecords()
Returns the tabular data records as an iterator object.
public
getRecords([array<string|int, mixed> $header = [] ]) : Iterator<int, array<string|int, mixed>>
Parameters
- $header : array<string|int, mixed> = []
-
an optional header mapper to use instead of the tabular data header
Tags
Return values
Iterator<int, array<string|int, mixed>>getRecordsAsObject()
public
getRecordsAsObject(T> $className[, array<string|int, string> $header = [] ]) : iterator<string|int, T>
Parameters
- $className : T>
- $header : array<string|int, string> = []
Tags
Return values
iterator<string|int, T>hasHeader()
public
hasHeader() : bool
Return values
boolinsert()
public
insert(array<string|int, mixed> ...$records) : int
Parameters
- $records : array<string|int, mixed>
Tags
Return values
intisEmpty()
public
isEmpty() : bool
Return values
boollast()
public
last() : array<string|int, mixed>
Return values
array<string|int, mixed>lastAsObject()
public
lastAsObject(class-string $className[, array<string|int, string> $header = [] ]) : object|null
Parameters
- $className : class-string
- $header : array<string|int, string> = []
Tags
Return values
object|nulllastOffset()
public
lastOffset() : int|null
Return values
int|nullmap()
Run a map over each container members.
public
map(callable(array<string|int, mixed>, int): TMap $callback) : Iterator<string|int, TMap>
Parameters
- $callback : callable(array<string|int, mixed>, int): TMap
Tags
Return values
Iterator<string|int, TMap>nth()
public
nth(int $nth) : array<string|int, mixed>
Parameters
- $nth : int
Tags
Return values
array<string|int, mixed>nthAsObject()
public
nthAsObject(int $nth, T> $className[, array<string|int, string> $header = [] ]) : object|null
Parameters
- $nth : int
- $className : T>
- $header : array<string|int, string> = []
Tags
Return values
object|nullrecordCount()
public
recordCount() : int
Return values
intto()
public
to(TabularDataWriter $dataStorage[, int $options = self::INCLUDE_HEADER ]) : int
Parameters
- $dataStorage : TabularDataWriter
- $options : int = self::INCLUDE_HEADER
Tags
Return values
inttruncate()
public
truncate() : void
update()
public
update(Predicate|Closure|callable $where, array<string|int, mixed> $record) : int
Parameters
- $where : Predicate|Closure|callable
- $record : array<string|int, mixed>
Tags
Return values
intfilterInsertRecord()
private
filterInsertRecord(array<string|int, mixed> $record) : bool
Parameters
- $record : array<string|int, mixed>
Return values
boolfilterPredicate()
private
filterPredicate(Predicate|Closure|callable $predicate) : Predicate
Parameters
- $predicate : Predicate|Closure|callable
Return values
PredicatefilterUpdateRecord()
private
filterUpdateRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
- $record : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>formatInsertRecord()
private
formatInsertRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
- $record : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>nthRow()
private
nthRow(int $nth, string $method) : array<string|int, mixed>
Parameters
- $nth : int
- $method : string
Tags
Return values
array<string|int, mixed>rowToRecord()
private
rowToRecord(array<string|int, mixed> $row, array<string|int, mixed> $header) : array<string|int, mixed>
Parameters
- $row : array<string|int, mixed>
- $header : array<string|int, mixed>
Return values
array<string|int, mixed>validateRecord()
Validates a record.
private
validateRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
- $record : array<string|int, mixed>