承接 apfelfrisch/data-transfer-object 相关项目开发

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

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

apfelfrisch/data-transfer-object

最新稳定版本:0.2.3

Composer 安装命令:

composer require apfelfrisch/data-transfer-object

包简介

README 文档

README

Unit Test Static Analysis

This package is heavily inspired by spatie/data-transfer-object. The main difference is that the DataTransferObject doesn't come with a constructor. That makes the Initialization less magical which is nicer for static analysis.

Installation

You can install the package via composer:

composer require apfelfrisch/data-transfer-object

Usage

Here's what a DTO looks like:

use Apfelfrisch\DataTransferObject;
use Apfelfrisch\DataTransferObject\Casters\DateTimeCast;

class MyDTO extends DataTransferObject
{
    public function __construct(
        public int $a,

        public float $b,

        public OtherDTO $otherDTO,
        
        #[DateTimeCast]
        public DateTime $date,
    ) { }
}

You could construct this DTO with Parameter casting like so:

$dto = MyDTO::fromArrayWithCast([
    'a' => 1,
    'b' => 2.2,
    'otherDTO' => ['id' => 3],
    'date' => '2021-05-01'
);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-01