saedyousef/dataobject
最新稳定版本:v1.0.3
Composer 安装命令:
composer require saedyousef/dataobject
包简介
PHP Data Object
README 文档
README
PHP Data Object
PHP Light DataObject with minimum implementation.
Installation
From the command line run:
composer require saedyousef/dataobject
Usage
With the package now installed, you can implement the main Interface DataObject and by using the trait DataObjectTrait that have all the methods implemented for you.
Here is an example of a class PostDataObject that implements the DataObject interface :
use SY\DataObject\Contracts\DataObject; use SY\DataObject\Support\DataObjectTrait; use SY\DataObject\Support\ObjectReadAccess; use SY\DataObject\Support\ObjectWriteAccess; /** * @property int|null id * @property string title * @property string body */ class PostDataObject implements DataObject { use DataObjectTrait; use ObjectReadAccess; use ObjectWriteAccess; // If you need to write object properties. public function __construct(array $properties = []) { $this->_properties = [ 'id' => null, 'title' => '', 'body' => '' ]; $this->hydrate($properties); } /** * @return int|null */ public function getId() { return $this->id; } /** * @return string */ public function getTitle(): string { return $this->title; } }
统计信息
- 总下载量: 427
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-02