class CsvSchema (View source)

Properties

protected int $rowIndex

The row index of the CSV header.

protected string[] $headerCells

The header cells.

protected array $fieldsMap

The map between the CSV field indexes and the object fields/attributes.

protected string[] $missingHeaders

The list of missing headers.

protected string[] $unrecognizedHeaders

The list of unrecognized headers.

Methods

__construct(int $rowIndex, array $headerCells, string[]|Generator $staticHeaders, array $attributesMap)

Initialize the instance.

int
getRowIndex()

Get the row index of the CSV header.

bool
someHeaderRecognized()

Do some of the headers have been recognized?

string[]
getMissingHeaders()

Get the list of missing headers.

array
getStaticValues(array $cells)

Get the values of the cells associated to the static headers.

array
getAttributesValues(array $cells)

Get the values of the cells associated to the attributes.

string[]
getUnrecognizedHeaders()

Get the list of unrecognized headers.

parseStaticHeaders(string[]|Generator $staticHeaders)

No description

parseAttributeHeaders(array $attributesMap)

No description

Details

__construct(int $rowIndex, array $headerCells, string[]|Generator $staticHeaders, array $attributesMap)

Initialize the instance.

Parameters

int $rowIndex

the row index of the CSV header

array $headerCells

the list of the header cells

string[]|Generator $staticHeaders
array $attributesMap

int getRowIndex()

Get the row index of the CSV header.

Return Value

int

bool someHeaderRecognized()

Do some of the headers have been recognized?

Return Value

bool

string[] getMissingHeaders()

Get the list of missing headers.

Return Value

string[]

array getStaticValues(array $cells)

Get the values of the cells associated to the static headers.

Parameters

array $cells

Return Value

array

keys are the static field names, values are the field values (strings)

array getAttributesValues(array $cells)

Get the values of the cells associated to the attributes.

Parameters

array $cells

Return Value

array

keys are the index of the attribute keys, values are the field values. In case of single-line attributes, values are strings. In case of multi-column attributes, values are arrays whose keys are the sub-headers and values the strings.

string[] getUnrecognizedHeaders()

Get the list of unrecognized headers.

Return Value

string[]

private parseStaticHeaders(string[]|Generator $staticHeaders)

No description

Parameters

string[]|Generator $staticHeaders

private parseAttributeHeaders(array $attributesMap)

No description

Parameters

array $attributesMap