sicram / automapper
一个用于映射对象的简单库
0.0.5
2023-05-17 22:23 UTC
Requires
- json-mapper/json-mapper: ^2.17
README
介绍
待办:一个用于映射对象的简单库。
入门
- 使用 composer 安装库
composer require sicram/automapper
- 在 provider 中注册库
use Sicram\Automapper\Automapper; use Sicram\Automapper\IAutomapper; $this->app->bind(IAutomapper::class, Automapper::class);
- 使用示例
use Sicram\Automapper\IAutomapper; class ExampleController extends Controller { public function __construct(private IAutomapper $_automapper) { } public function index() { $source = new Source(); $source->name = 'John'; $source->age = 20; $destination = $this->_automapper->map($source, Destination::class); return $destination; } } # Build and Test You can use the following class to build a test with doubles: ```php use Sicram\Automapper\Tests\Supports\Doubles\Automapper\StubAutomapper;
贡献
待办:解释其他用户和开发者如何贡献以使代码更好。