enrise / maparea
A data mapping library.
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 11
Forks: 2
Open Issues: 0
pkg:composer/enrise/maparea
Requires
- php: ^7.0
- mtdowling/jmespath.php: ^2.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.3
- phpunit/phpunit: ^6.1
- symfony/yaml: ^3.2
Suggests
- symfony/yaml: Allows you to use the built in YamlLoader
This package is not auto-updated.
Last update: 2022-10-10 07:04:25 UTC
README
This is an old repository that is no longer used or maintained. We advice to no longer use this repository.
Original README can be found below:
Maparea 
This is a PHP mapping helper utility. It's useful when you want to convert a certain array-structure into another structure. The definitions could be declared in a yaml-structure, so it's easy to verify the input and of the mapping.
Definition
The definition is easiest done by using yaml. This project is using JMESpath, so you can define the mapping like this:
# route.yml id: from: uuid distance: from: plan.distance service_class: \Enrise\DistanceMapper
# map using route.yml $mapper = new \Enrise\Maparea\Mapper(); $raw = [ 'uuid' => 'F2001E99-98E6-4C50-A965-C694EC44B810', 'plan' => [ 'distance' => 1223 ] ]; $mapper = Mapper::withLoader(new YamlLoader(__DIR__."/resources/yaml")); $mappedData = $mapper->mapDataWithLoader($raw, "route.yaml"); // $mappedData [ 'id' => 'F2001E99-98E6-4C50-A965-C694EC44B810', 'distance' => 1.223 ]