chriha/data-objects
最新稳定版本:v1.0.1
Composer 安装命令:
composer require chriha/data-objects
包简介
A PHP package to create immutable data objects with validation and transformation capabilities.
README 文档
README
A PHP project for working with flexible data objects, supporting dynamic properties and array initialization.
Features
- Dynamic Properties: Easily set and get properties on data objects.
- Array Initialization: Instantiate objects with an associative array of properties.
- Extensible: Create your own data object classes by extending the base
DataObject.
Example Usage
use ClipMyHorseTV\DataObject; use ClipMyHorseTV\DataObjects\Attributes\MapFrom; class Person extends DataObject { #[MapFrom('name_attr')] public string $name; public int $age; } $person = Person::from(['name_attr' => 'Alice', 'age' => 30]); echo $person->name; // Alice echo $person->age; // 30
Running Tests
This project uses PestPHP for testing.
To run the tests:
composer install ./vendor/bin/pest
Directory Structure
src/- Source code for data objectstests/- PestPHP test suite
Requirements
- PHP 8.3+
- Composer
License
MIT
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-15