Converter
in package
Table of Contents
Properties
- $convertAllAssociative : callable
- $convertAllNumeric : callable
- $convertAssociative : callable
- $convertFirstColumn : callable
- $convertNumeric : callable
- $convertOne : callable
Methods
- __construct() : mixed
- convertAllAssociative() : array<int, array<string, mixed>>
- convertAllNumeric() : array<int, array<int, mixed>>
- convertAssociative() : array<string, mixed>|false
- convertFirstColumn() : array<int, mixed>
- convertNumeric() : array<int, mixed>|false
- convertOne() : mixed|false
- compose() : callable(T): T|null
- Creates a composition of the given set of functions
- convertEmptyStringToNull() : T|null
- createConvert() : callable
- Creates a function that will be applied to the return value of Statement::fetch*() or an identity function if no conversion is needed
- createConvertAll() : callable
- Creates a function that will be applied to the return value of Statement::fetchAll*() or an identity function if no transformation is required
- createConvertRow() : callable|null
- Creates a function that will convert each array-row retrieved from the database
- createConvertValue() : callable|null
- Creates a function that will convert each individual value retrieved from the database
- createMapper() : callable
- Creates a function that maps each value of the array using the given function
- id() : T
- rightTrimString() : T|string
Properties
$convertAllAssociative
private
callable
$convertAllAssociative
$convertAllNumeric
private
callable
$convertAllNumeric
$convertAssociative
private
callable
$convertAssociative
$convertFirstColumn
private
callable
$convertFirstColumn
$convertNumeric
private
callable
$convertNumeric
$convertOne
private
callable
$convertOne
Methods
__construct()
public
__construct(bool $convertEmptyStringToNull, bool $rightTrimString, int|null $case) : mixed
Parameters
- $convertEmptyStringToNull : bool
-
Whether each empty string should be converted to NULL
- $rightTrimString : bool
-
Whether each string should right-trimmed
- $case : int|null
-
Convert the case of the column names (one of CASE_LOWER and CASE_UPPER)
convertAllAssociative()
public
convertAllAssociative(array<int, array<string, mixed>> $data) : array<int, array<string, mixed>>
Parameters
- $data : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>convertAllNumeric()
public
convertAllNumeric(array<int, array<int, mixed>> $data) : array<int, array<int, mixed>>
Parameters
- $data : array<int, array<int, mixed>>
Return values
array<int, array<int, mixed>>convertAssociative()
public
convertAssociative(array<string, mixed>|false $row) : array<string, mixed>|false
Parameters
- $row : array<string, mixed>|false
Return values
array<string, mixed>|falseconvertFirstColumn()
public
convertFirstColumn(array<int, mixed> $data) : array<int, mixed>
Parameters
- $data : array<int, mixed>
Return values
array<int, mixed>convertNumeric()
public
convertNumeric(array<int, mixed>|false $row) : array<int, mixed>|false
Parameters
- $row : array<int, mixed>|false
Return values
array<int, mixed>|falseconvertOne()
public
convertOne(mixed|false $value) : mixed|false
Parameters
- $value : mixed|false
Return values
mixed|falsecompose()
Creates a composition of the given set of functions
private
compose(callable(T): T ...$functions) : callable(T): T|null
Parameters
- $functions : callable(T): T
-
The functions to compose
Tags
Return values
callable(T): T|nullconvertEmptyStringToNull()
private
static convertEmptyStringToNull(T $value) : T|null
Parameters
- $value : T
Tags
Return values
T|nullcreateConvert()
Creates a function that will be applied to the return value of Statement::fetch*() or an identity function if no conversion is needed
private
createConvert(callable|null $function, callable $id) : callable
Parameters
- $function : callable|null
-
The function that will convert each tow
- $id : callable
-
Identity function
Return values
callablecreateConvertAll()
Creates a function that will be applied to the return value of Statement::fetchAll*() or an identity function if no transformation is required
private
createConvertAll(callable|null $function, callable $id) : callable
Parameters
- $function : callable|null
-
The function that will transform each value
- $id : callable
-
Identity function
Return values
callablecreateConvertRow()
Creates a function that will convert each array-row retrieved from the database
private
createConvertRow(callable|null $function, int|null $case) : callable|null
Parameters
- $function : callable|null
-
The function that will convert each value
- $case : int|null
-
Column name case
Return values
callable|null —The resulting function or NULL if no conversion is needed
createConvertValue()
Creates a function that will convert each individual value retrieved from the database
private
createConvertValue(bool $convertEmptyStringToNull, bool $rightTrimString) : callable|null
Parameters
- $convertEmptyStringToNull : bool
-
Whether each empty string should be converted to NULL
- $rightTrimString : bool
-
Whether each string should right-trimmed
Return values
callable|null —The resulting function or NULL if no conversion is needed
createMapper()
Creates a function that maps each value of the array using the given function
private
createMapper(callable $function) : callable
Parameters
- $function : callable
-
The function that maps each value of the array
Return values
callableid()
private
static id(T $value) : T
Parameters
- $value : T
Tags
Return values
TrightTrimString()
private
static rightTrimString(T $value) : T|string
Parameters
- $value : T