kosmcode/simple-dto 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kosmcode/simple-dto

最新稳定版本:1.0.0

Composer 安装命令:

composer require kosmcode/simple-dto

包简介

Package to create simple flexible DTOs

README 文档

README

License: MIT

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-20