class Column implements ColumnInterface (View source)

Shared Column implementation

Brand-neutral, immutable column of response data. Every brand stores the same thing — a key plus an ordered bag of values — so all behaviour lives here and is instantiated directly by each Response's addColumn(). What differs between brands is only the value type: CNR responses are plaintext and carry strings, IBS/Moniker responses are JSON and carry arbitrary values (nested arrays and objects included). That difference used to be expressed as a TValue template parameter narrowed by a brand subclass, but the narrowing never survived {\CNIC\ColumnInterface} — which is not generic — so no consumer holding the interface (every reachable path: getColumn()/getColumns()) ever saw it. It is expressed instead as a native return type on the interface itself, exactly as {\CNIC\self::getDateTimeByIndex()} already narrows: {\CNIC\self::getStringByIndex()}.

Methods

__construct(string $columnName, array $data)

Constructor

string
getKey()

Get column name

int
getLength()

Get the number of data entries this column holds

array
getData()

Get column data

mixed
getDataByIndex(int $recordIndex)

Get column data at given index

string|null
getStringByIndex(int $recordIndex)

Get column data at given index, narrowed to a string.

getDateTimeByIndex(int $recordIndex)

Get column data at given index, parsed as a date/time value.

Details

__construct(string $columnName, array $data)

Constructor

Parameters

string $columnName
array $data

Column Data

string getKey()

Get column name

Return Value

string

int getLength()

Get the number of data entries this column holds

Return Value

int

array getData()

Get column data

Return Value

array

mixed getDataByIndex(int $recordIndex)

Get column data at given index

Parameters

int $recordIndex

Return Value

mixed

string|null getStringByIndex(int $recordIndex)

Get column data at given index, narrowed to a string.

Returns null for an out-of-range index or a non-string value. CNR cells are always strings; IBS/Moniker JSON cells may be nested arrays or objects, which yield null here — use {\CNIC\self::getDataByIndex()} for the raw value in that case.

Parameters

int $recordIndex

Return Value

string|null

ApiDateTime|null getDateTimeByIndex(int $recordIndex)

Get column data at given index, parsed as a date/time value.

Opt-in narrowing over {\CNIC\self::getDataByIndex()}: returns null for an out-of-range index, a non-string value, or a string {\CNIC\ApiDateTime::tryFrom()} cannot parse. There is no throwing variant here — use ApiDateTime::from($col->getDataByIndex($recordIndex)) directly if an unparsable value should be a loud failure instead.

Parameters

int $recordIndex

Return Value

ApiDateTime|null