senet-eindhoven/cartograph
最新稳定版本:4.0.1
Composer 安装命令:
composer require senet-eindhoven/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 senet-eindhoven/cartograph:^4.0
Getting Started
To use this library create an instance of the MapperService, using your preffered MappingRepositoryInterface
<?php use Senet\Cartograph\MapperService; use Senet\Cartograph\Mapping\DirectMapping; use Senet\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.
统计信息
- 总下载量: 6.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-14