Skip to content

williamrijksen/Maparea

 
 

Repository files navigation

Maparea Travis build

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
# 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' => 1223
]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%