Fr3nch13/CakePHP Utilities

FieldTypeConverter
in package

A callable class to be used for processing each of the rows in a statement result, so that the values are converted to the right PHP types.

Table of Contents

Properties

$_driver  : DriverInterface
The driver object to be used in the type conversion
$_typeMap  : array<string|int, TypeInterface>
An array containing the name of the fields and the Type objects each should use when converting them.
$batchingTypeMap  : array<string, array<string|int, mixed>>
An array containing the name of the fields and the Type objects each should use when converting them using batching.
$types  : array<string|int, TypeInterface|BatchCastingInterface>
An array containing all the types registered in the Type system at the moment this object is created. Used so that the types list is not fetched on each single row of the results.

Methods

__construct()  : mixed
Builds the type map
__invoke()  : array<string, mixed>
Converts each of the fields in the array that are present in the type map using the corresponding Type class.

Properties

$_typeMap

An array containing the name of the fields and the Type objects each should use when converting them.

protected array<string|int, TypeInterface> $_typeMap

$batchingTypeMap

An array containing the name of the fields and the Type objects each should use when converting them using batching.

protected array<string, array<string|int, mixed>> $batchingTypeMap

$types

An array containing all the types registered in the Type system at the moment this object is created. Used so that the types list is not fetched on each single row of the results.

protected array<string|int, TypeInterface|BatchCastingInterface> $types

Methods

__invoke()

Converts each of the fields in the array that are present in the type map using the corresponding Type class.

public __invoke(array<string|int, mixed> $row) : array<string, mixed>
Parameters
$row : array<string|int, mixed>

The array with the fields to be casted

Return values
array<string, mixed>

        
On this page

Search results