TransformerOutputActiveRecord
extends Transformer
in package
Table of Contents
Properties
- $registry : Registry|null
- $dataMap : array<string|int, mixed>
- $defaultConfig : array<string|int, mixed>
Methods
- getDataMap() : array<string|int, mixed>
- Get data map
- setDataMap() : void
- Set data map
- setDefaultConfig() : void
- Set default config
- setRegistry() : void
- Called automatically by DI container via @Inject annotation Whenever we are on PHP 8.1 we can switch this to PHP attributes
- transform() : mixed|null
- Transform data
- transformAll() : array<string|int, mixed>
- Transform collection
- validate() : bool|array<string|int, mixed>
- validateAll() : bool|array<string|int, mixed>
- Validate collection
- cast() : mixed
- Cast Value
- filter() : mixed
- Filter Value
- format() : mixed
- Format Value Looks for possible formatter in the config, tries to get it from the registry and calls the format method on it.
- getDefaultConfig() : array<string|int, mixed>
- Get default config
- normaliseConfig() : array<string|int, mixed>
- Normalise config
- validateKey() : bool|array<string|int, mixed>
- Validate Value
Properties
$registry
public
Registry|null
$registry
$dataMap
protected
array<string|int, mixed>
$dataMap
= []
$defaultConfig
protected
array<string|int, mixed>
$defaultConfig
= []
Methods
getDataMap()
Get data map
public
getDataMap() : array<string|int, mixed>
Return values
array<string|int, mixed>setDataMap()
Set data map
public
setDataMap(array<string|int, mixed> $dataMap) : void
Data map is an associative array. Key is the key in the source data and value is either boolean true
- to include the data as is or a a string field name to map the value
- to in the output.
Parameters
- $dataMap : array<string|int, mixed>
setDefaultConfig()
Set default config
public
setDefaultConfig(array<string|int, mixed> $defaultConfig) : void
Parameters
- $defaultConfig : array<string|int, mixed>
setRegistry()
Called automatically by DI container via @Inject annotation Whenever we are on PHP 8.1 we can switch this to PHP attributes
public
setRegistry(Registry $registry) : void
Parameters
- $registry : Registry
Tags
transform()
Transform data
public
transform(mixed $data[, mixed $options = [] ]) : mixed|null
Transforms data from one format to another.
Default functionality is to map input data to output data (or vice versa) using a data map. Data map config also allows specification of type cast and callable formatter.
Parameters
- $data : mixed
- $options : mixed = []
Return values
mixed|nulltransformAll()
Transform collection
public
transformAll(array<string|int, mixed> $collection[, array<string|int, mixed>|null $options = [] ]) : array<string|int, mixed>
Parameters
- $collection : array<string|int, mixed>
- $options : array<string|int, mixed>|null = []
Return values
array<string|int, mixed>validate()
public
validate(mixed $data[, array<string|int, mixed>|null $options = [] ]) : bool|array<string|int, mixed>
Parameters
- $data : mixed
- $options : array<string|int, mixed>|null = []
Return values
bool|array<string|int, mixed> —Returns true on success or array of errors.
validateAll()
Validate collection
public
validateAll(array<string|int, mixed> $collection[, array<string|int, mixed>|null $options = [] ]) : bool|array<string|int, mixed>
Parameters
- $collection : array<string|int, mixed>
- $options : array<string|int, mixed>|null = []
Return values
bool|array<string|int, mixed> —Returns true on success or array of errors.
cast()
Cast Value
private
cast(mixed $value, array<string|int, mixed> $config) : mixed
Parameters
- $value : mixed
- $config : array<string|int, mixed>
filter()
Filter Value
private
filter(mixed $value, array<string|int, mixed> $config) : mixed
Parameters
- $value : mixed
- $config : array<string|int, mixed>
format()
Format Value Looks for possible formatter in the config, tries to get it from the registry and calls the format method on it.
private
format(mixed $value, array<string|int, mixed> $config) : mixed
Parameters
- $value : mixed
- $config : array<string|int, mixed>
getDefaultConfig()
Get default config
private
getDefaultConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>normaliseConfig()
Normalise config
private
normaliseConfig(bool|int|string|array<string|int, mixed> $config, string|int $inputKey[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $config : bool|int|string|array<string|int, mixed>
- $inputKey : string|int
- $options : array<string|int, mixed> = []
Return values
array<string|int, mixed>validateKey()
Validate Value
private
validateKey(string $key, mixed $value, array<string|int, mixed> $config, array<string|int, mixed> $data[, array<string|int, mixed>|null $options = [] ]) : bool|array<string|int, mixed>
Returns boolean true or array of errors.
Parameters
- $key : string
- $value : mixed
- $config : array<string|int, mixed>
- $data : array<string|int, mixed>
- $options : array<string|int, mixed>|null = []