承接 yago-o/simple-dto 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

yago-o/simple-dto

最新稳定版本:1.0.4

Composer 安装命令:

composer require yago-o/simple-dto

包简介

Simple class for build php dto objects via PHPDoc annotations.

README 文档

README

This is class for building simple DTO objects via PHPDoc annotations. Includes scalar, array and type validation.

Example:

class DtoClass extends SimpleDto
{
    /** @var integer */
    private $id;

    /** @var string|null */
    private $name;

    /** @var int[] */
    private $idList;

    /** @var TypeClass */
    private $typeClass;

    /** @var float */
    private $rating = 3.5;
    
    /** @var bool */
    private $isAdmin = false;

    /**
     * @return int
     */
    public function getId(): int
    {
        return $this->id;
    }

    /**
     * @return null|string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @return int[]
     */
    public function getIdList(): array
    {
        return $this->idList;
    }

    /**
     * @return TypeClass
     */
    public function getTypeClass(): TypeClass
    {
        return $this->typeClass;
    }

    /**
     * @return float
     */
    public function getRating(): float
    {
        return $this->rating;
    }
    
    /**
     * @return bool
     */
    public function isAdmin(): bool
    {
        return $this->isAdmin;
    }
}

class TypeClass
{
}


$dto = new DtoClass([
    'id' => 5,
    'name' => 'Ivan',
    'idList' => [1,2,3,4,5],
    'typeClass' => new TypeClass(),
    'isAdmin' => true,
]);

$id = $dto->getId(); // 5
$name = $dto->getName(); // 'Ivan'
$idList = $dto->getIdList(); // [1,2,3,4,5]
$rating = $dto->getRating(); // 3.5
$typeClass = $dto->getTypeClass(); // TypeClass object
$isAdmin = $dto->isAdmin(); // true

Installation:

composer require yago-o/simple-dto

Caveats:

  • All types may be arrayable.
  • All class properties must be described via PHPDoc annotation.
  • To use custom classes on properties you must write full class name include namespace.

统计信息

  • 总下载量: 10.9k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固