frank-houweling/cartograph
Composer 安装命令:
composer require frank-houweling/cartograph
包简介
Map objects to objects
README 文档
README
This library is used to Map PHP object to other objects
Installation
Install this library using composer
composer require frank-houweling/cartograph
Getting Started
To use this library create an instance of the MapperService, using your preffered MappingRepositoryInterface
<?php use FrankHouweling\Cartograph\MapperService; use FrankHouweling\Cartograph\Mapping\DirectMapping; use FrankHouweling\Cartograph\MappingRepository; $foo = new Foo(); $bar = new Bar(); // Initiate the MapperService $mappingRepository = new MappingRepository(); $mapperService = new MapperService($mappingRepository); // Register a mapping from Foo, to Bar using the DirectMapping $mappingRepository->addMapping(Foo::class, Bar::class, DirectMapping::class); // Map Foo -> Bar. Will fetch the previously registered Mapping $mapperService->map($foo, $bar);
Creating custom Mappings
The DirectMapping uses reflection to map attributes 1:1. Should this not meet your requirements, you can create
a custom mapping by implementing the MappingInterface and registering it to the MappingRepository as shown above.
统计信息
- 总下载量: 31.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-08-22