stratadox / hydration-mapper
v2.4
2018-05-06 15:59 UTC
Requires
- php: >=7.1
- stratadox/hydration-mapper-contracts: ^0.3.0
- stratadox/hydration-mapping: ^v2.1
- stratadox/hydrator: ^v3.2
- stratadox/proxy: ^0.1
- stratadox/specification-interfaces: ^1.0
Requires (Dev)
- phpstan/phpstan: ^0.9.2
- phpunit/phpunit: ^7.0
- satooshi/php-coveralls: ^2.0
- stratadox/specification: ^1.0
README
用于水合目的的映射构建器;将数组或类似数组的结构映射到对象属性,以组装表示业务领域的对象。
使用示例
<?php $hydrator = Mapper::forThe(Book::class) ->property('title', Has::one(Title::class) ->with('title') ) ->property('isbn', Has::one(Isbn::class) ->with('code', In::key('id')) ->with('version', Call::the(function ($data) { return strlen($data['id']); })) ) ->property('author', Has::one(Author::class) ->with('firstName', In::key('author_first_name')) ->with('lastName', In::key('author_last_name')) ) ->property('contents', Has::many(ChapterProxy::class) ->containedInA(Chapters::class) ->loadedBy(new ChapterLoaderFactory) ) ->property('format') ->finish();
安装
使用Composer安装
composer require stratadox/hydration-mapper
更多详情
更多信息,请查看Hydrate仓库