You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Date (4) + Encoding (3), base64 round-trip, hash comparison
06-all-rules.php
All 32 rules smoke test
Complete parameter reference
API Quick Reference
// 1. Engine API (raw array)$engine = (newTransformerServiceProvider())->createEngine();
$result = $engine->transform(
['name' => 'hello world', 'cpf' => '123.456.789-09'],
['name' => ['camel_case'], 'cpf' => ['cpf_to_digits']]
);
$result->get('name'); // "helloWorld"$result->getTransformedData(); // full transformed array$result->wasTransformed(); // bool$result->transformedFields(); // list of changed field names$result->isFieldTransformed('name'); // bool$result->transformationCount(); // int — number of logged changes (0 if tracking disabled)$result->transformationsFor('name'); // list<FieldTransformation> per-field log$result->merge($otherResult); // combine two results// 2. Attribute API (DTO)class MyDto {
#[Transform('camel_case')]
publicstring$name = '';
#[Transform(['hash', ['algo' => 'sha256']])]
publicstring$token = '';
}
$result = (newTransformerServiceProvider())->createAttributeTransformer()->transform($dto);
// 3. Inline rule instance (no alias needed)useKaririCode\Transformer\Rule\String\CamelCaseRule;
$engine->transform(['v' => 'hello'], ['v' => [newCamelCaseRule()]]);
// 4. Multi-rule ordered pipeline (rules run sequentially)$engine->transform(['v' => 'Hello World'], ['v' => ['snake_case', 'reverse']]);
// 5. Dot notation (access nested keys)$engine->transform($nested, ['user.profile.name' => ['pascal_case']]);
// 6. TransformerConfigurationuseKaririCode\Transformer\Configuration\TransformerConfiguration;
$engine = (newTransformerServiceProvider())->createEngine(
newTransformerConfiguration(trackTransformations: false) // no log overhead
);
All 32 Rules — Parameter Reference
Parameters shown are confirmed from the actual rule implementations.
Brazilian (4)
Alias
Input
Output
Params
cpf_to_digits
123.456.789-09
12345678909
none
cnpj_to_digits
11.222.333/0001-81
11222333000181
none
cep_to_digits
60.175-110
60175110
none
phone_format
88999998888
(88) 99999-8888
none; input must be exactly 10 or 11 digits — no country code
Data (5)
Alias
Params
Notes
csv_to_array
separator(','), enclosure('"'), header(true)
header=true → first row used as keys; header=false → indexed rows
json_decode
assoc(true)
Converts JSON string to PHP array
json_encode
flags(JSON_UNESCAPED_UNICODE|SLASHES)
Converts any value to JSON string
array_to_key_value
key('id'), value('name')
Input must be a list of objects, e.g. [['id'=>1,'name'=>'A'],…]
implode
separator(',')
Joins array elements into a string
Date (4)
IMPORTANT: Each date rule has a from param matching the input date string format. If the format doesn't match, the rule silently returns the original value unchanged.