enrise / maparea
此包已被废弃,不再维护。未建议替代包。
此包最新版本(dev-master)没有可用的许可证信息。
数据映射库。
dev-master
2022-10-08 18:32 UTC
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
这是一个不再使用或维护的旧仓库。我们建议不再使用此仓库。
原始 README 可在下方找到
Maparea 
这是一个 PHP 映射辅助工具。当您想将某种数组结构转换为另一种结构时很有用。定义可以声明在 yaml 结构中,因此很容易验证输入和映射。
定义
定义最简单的方法是使用 yaml。此项目使用 JMESpath,因此您可以像这样定义映射
# 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 ]