Documentation

Buffer
in package
implements TabularData

FinalYes

Table of Contents

Interfaces

TabularData

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
throws
SyntaxError

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
self

addValidator()

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
self

fetchColumn()

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
throws
ReflectionException
Return values
object|null

firstOffset()

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

from()

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
throws
RuntimeException|SyntaxError

If the column names can not be found

Return values
self

getHeader()

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
throws
SyntaxError
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
template
throws
Exception
throws
MappingFailed
throws
TypeCastingFailed
Return values
iterator<string|int, T>

hasHeader()

public hasHeader() : bool
Return values
bool

insert()

public insert(array<string|int, mixed> ...$records) : int
Parameters
$records : array<string|int, mixed>
Tags
throws
CannotInsertRecord
Return values
int

isEmpty()

public isEmpty() : bool
Return values
bool

last()

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
throws
ReflectionException
Return values
object|null

lastOffset()

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

map()

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
template
throws
SyntaxError
Return values
Iterator<string|int, TMap>

nth()

public nth(int $nth) : array<string|int, mixed>
Parameters
$nth : int
Tags
throws
InvalidArgument
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
template
throws
InvalidArgument
throws
ReflectionException
Return values
object|null

recordCount()

public recordCount() : int
Return values
int

truncate()

public truncate() : void

filterInsertRecord()

private filterInsertRecord(array<string|int, mixed> $record) : bool
Parameters
$record : array<string|int, mixed>
Return values
bool

filterUpdateRecord()

private filterUpdateRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
$record : array<string|int, mixed>
Tags
throws
CannotInsertRecord
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
throws
CannotInsertRecord
Return values
array<string|int, mixed>

nthRow()

private nthRow(int $nth, string $method) : array<string|int, mixed>
Parameters
$nth : int
$method : string
Tags
throws
InvalidArgument
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>
Tags
throws
CannotInsertRecord

If the validation failed

Return values
array<string|int, mixed>

        
On this page

Search results