apfelfrisch/data-transfer-object
最新稳定版本:0.2.3
Composer 安装命令:
composer require apfelfrisch/data-transfer-object
包简介
README 文档
README
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
其他信息
- 授权协议: MIT
- 更新时间: 2021-05-01