AlterArrayPropertyTrait uses trait:short, trait:short
Table of Contents
Methods
- alterArrayElements() : array<string|int, mixed>
- Alters all elements in an array.
- alterArrayProperty() : array<string|int, mixed>
- Transform a string expression separated by semi-colon ';' to creates an array.
- alterFloatProperty() : array<string|int, mixed>|float
- Cast a value to float. If the value is an array, all elements in the array are casted.
- alterIntProperty() : array<string|int, mixed>|float
- Cast a value to integer.
Methods
alterArrayElements()
Alters all elements in an array.
public
alterArrayElements(array<string|int, mixed> $array[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $options : array<string|int, mixed> = []
Tags
Return values
array<string|int, mixed>alterArrayProperty()
Transform a string expression separated by semi-colon ';' to creates an array.
public
alterArrayProperty(mixed $value[, array<string|int, mixed> $options = [] ][, bool &$modified = false ]) : array<string|int, mixed>
You can chain multiple alter definition to transform the content of the array, ex:
Property::CATEGORY => [ Alter::ARRAY , Alter::CLEAN , Alter::JSON_PARSE ] ,
The previous example transform the 'category' string in an Array and after remove all null or empty array elements and JSON parse all elements.
Parameters
- $value : mixed
- $options : array<string|int, mixed> = []
- $modified : bool = false
Tags
Return values
array<string|int, mixed>alterFloatProperty()
Cast a value to float. If the value is an array, all elements in the array are casted.
public
alterFloatProperty(mixed $value[, bool &$modified = false ]) : array<string|int, mixed>|float
Property::PRICE => [ Alter::FLOAT ] ,
Parameters
- $value : mixed
- $modified : bool = false
Return values
array<string|int, mixed>|floatalterIntProperty()
Cast a value to integer.
public
alterIntProperty(mixed $value[, bool &$modified = false ]) : array<string|int, mixed>|float
If the value is an array, all elements in the array are casted.
Property::PRICE => [ Alter::INT ] ,
Parameters
- $value : mixed
- $modified : bool = false