mirror of
https://github.com/danog/Valinor.git
synced 2024-11-27 04:34:48 +01:00
b7a7d22993
This modifier can be used to change paths in the source data using a dot notation. The mapping is done using an associative array of path mappings. This array must have the source path as key and the target path as value. The source path uses the dot notation (eg `A.B.C`) and can contain one `*` for array paths (eg `A.B.*.C`). ```php final class Country { /** @var City[] */ public readonly array $cities; } final class City { public readonly string $name; } $source = new \CuyZ\Valinor\Mapper\Source\Modifier\PathMapping([ 'towns' => [ ['label' => 'Ankh Morpork'], ['label' => 'Minas Tirith'], ], ], [ 'towns' => 'cities', 'towns.*.label' => 'name', ]); // After modification this is what the source will look like: [ 'cities' => [ ['name' => 'Ankh Morpork'], ['name' => 'Minas Tirith'], ], ]; (new \CuyZ\Valinor\MapperBuilder()) ->mapper() ->map(Country::class, $source); ``` |
||
---|---|---|
.. | ||
Attribute | ||
Fixture | ||
Object | ||
Other | ||
Source | ||
InterfaceInferringMappingTest.php | ||
NamedConstructorTest.php | ||
ObjectBindingMappingTest.php | ||
ReadonlyMappingTest.php | ||
SingleNodeMappingTest.php | ||
ValueAlteringMappingTest.php | ||
VariadicParameterMappingTest.php | ||
VisitorMappingTest.php |