AlterListififyPropertyTrait
Provides a method to transform a string or array into a normalized list string.
This trait is typically used in alteration pipelines to convert semicolon-separated strings or arrays into clean, formatted list strings with configurable separators.
The transformation process:
- Splits strings by a separator (default:
;) - Trims each element
- Removes empty elements
- Joins elements with a replacement separator (default:
PHP_EOL) - Returns a default value if the result is empty
The $modified flag is set to true if the resulting value differs from the original.
Tags
Table of Contents
Methods
- alterListifyProperty() : string|null
- Transforms a string or array into a normalized list string.
Methods
alterListifyProperty()
Transforms a string or array into a normalized list string.
public
alterListifyProperty(mixed $value[, array<string|int, mixed> $definition = [] ][, bool &$modified = false ]) : string|null
The transformation can be customized via the $definition array:
$definition[0](string): Input separator for strings (default:;)$definition[1](string): Output separator for joining (default:PHP_EOL)$definition[2](string|null): Default value if result is empty (default:null)
Parameters
- $value : mixed
-
The value to transform (string, array, or null)
- $definition : array<string|int, mixed> = []
-
Optional parameters: [separator, replace, default]
- $modified : bool = false
-
Reference flag indicating if the value was modified
Tags
Return values
string|null —The normalized list string, or default if empty