crudle / entity
一组实体辅助组件
v1.0
2016-10-24 18:26 UTC
Requires
- php: >=7.0
- ramsey/uuid: ^3.5
Requires (Dev)
- phpunit/phpunit: ^5.6
This package is not auto-updated.
Last update: 2024-09-28 19:47:31 UTC
README
此包包含各种东西,如私有不可变属性的特质,以及使用UUID使实体可识别。
安装
composer require crudle/entity
示例用法
use Crudle\Entity\Identity\IdentifiedByUuid; use Crudle\Entity\Property\PrivateImmutableAttributes; class MyEntity { use IdentifiedByUuid, PrivateImmutableAttributes; /** * @param string $description * @return MyEntity */ public function setDescription(string $description): MyEntity { return $this->set('description', $description); } /** * @return string * @throws \Crudle\Entity\Exception\UndefinedException * When a description has not yet been set */ public function getDescription(): string { return $this->getOrFail('description'); } } $myEntity = new MyEntity; $myEntity->getId(); // Crudle\Entity\Identity\Uuid $myOtherEntity = new MyEntity('fa8588c6-166d-400d-9b13-561704027e94');