The Transformer is a php package for transforming values or input. It is powered by the Laravel framework's validation components.
For example, preg_replace accepts the value to change as the 3rd argument: $input = ['phone_number'=>'123-456-3235']; $transformers = [ 'example'=>'preg_replace:/[^0-9]/,,:value:', ]; $transformer = new DataTransformer($input, $transformers); $transformer->transform(); Optional Transformation/Blank Input
$transformer = new DataTransformer($input, $transformers); $transformer->transform(); Note: This package uses Laravel's blank helper to determine blank/empty values.
You can use closures for transforming your value as well: $input = ['first_name'=>' Bob']; $transformers = [ 'first_name'=>['trim', function ($value) { // change the value.