kosmcode/simple-dto
最新稳定版本:1.0.0
Composer 安装命令:
composer require kosmcode/simple-dto
包简介
Package to create simple flexible DTOs
README 文档
README
Package to create simple&flexible DTOs - just magic :)
Create DTOs 'on the fly'
How to use
Create and extend class by AbstractDTO.. and this is all! You can define properties, but you don't have to.
Example class:
use Kosmcode\SimpleDto\AbstractDTO;
/**
* @method bool getExistsField()
* @method self setExistsField(bool $value)
*/
class ExampleDTO extends AbstractDTO
{
}
...
$exampleDTO = (new ExampleDTO())
->setExistsField(true);
$exampleDTO->getExistsField();
// true
$exampleDTO->isExistsField();
// true
$exampleDTO->hasNotExistsField();
// false
$exampleDTO->setNewFieldInFly('yes!');
$exampleDTO->hasNewFieldInFly();
// true
$exampleDTO->getNewFieldInFly();
// yes!
If the logic of any of magic methods doesn't suit you - just overwrite it ;)
abstract class \Kosmcode\SimpleDto\AbstractDTO {
protected function getFieldValue(string $methodName): mixed
protected function setFieldValue(string $methodName, mixed $value): self
protected function isFieldValue(string $methodName): bool
protected function hasFieldValue(string $methodName): bool
}
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-20