Converter
in package
Table of Contents
- $convertAllAssociative : callable
- $convertAllNumeric : callable
- $convertAssociative : callable
- $convertFirstColumn : callable
- $convertNumeric : callable
- $convertOne : callable
- __construct() : mixed
- convertAllAssociative() : list<string|int, array<string, mixed>>
- convertAllNumeric() : list<string|int, list<string|int, mixed>>
- convertAssociative() : array<string, mixed>|false
- convertFirstColumn() : list<string|int, mixed>
- convertNumeric() : list<string|int, mixed>|false
- convertOne() : mixed|false
- compose() : callable|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
-
Return values
mixed —convertAllAssociative()
public
convertAllAssociative(list<string|int, array<string, mixed>> $data) : list<string|int, array<string, mixed>>
Parameters
- $data : list<string|int, array<string, mixed>>
Return values
list<string|int, array<string, mixed>> —convertAllNumeric()
public
convertAllNumeric(list<string|int, list<string|int, mixed>> $data) : list<string|int, list<string|int, mixed>>
Parameters
- $data : list<string|int, list<string|int, mixed>>
Return values
list<string|int, list<string|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>|false —convertFirstColumn()
public
convertFirstColumn(list<string|int, mixed> $data) : list<string|int, mixed>
Parameters
- $data : list<string|int, mixed>
Return values
list<string|int, mixed> —convertNumeric()
public
convertNumeric(array<int, mixed>|false $row) : list<string|int, mixed>|false
Parameters
- $row : array<int, mixed>|false
Return values
list<string|int, mixed>|false —convertOne()
public
convertOne(mixed|false $value) : mixed|false
Parameters
- $value : mixed|false
Return values
mixed|false —compose()
Creates a composition of the given set of functions
private
compose(callable ...$functions) : callable|null
Parameters
- $functions : callable
Tags
Return values
callable|null —convertEmptyStringToNull()
private
static convertEmptyStringToNull(T $value) : T|null
Parameters
- $value : T
Tags
Return values
T|null —createConvert()
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
callable —createConvertAll()
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
callable —createConvertRow()
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
callable —id()
private
static id(T $value) : T
Parameters
- $value : T
Tags
Return values
T —rightTrimString()
private
static rightTrimString(T $value) : T|string
Parameters
- $value : T