qlimix/serializable
Composer 安装命令:
composer require qlimix/serializable
包简介
An interface that indicates the object is serializable
关键字:
README 文档
README
An interface that indicates the object is serializable.
Install
Using Composer:
$ composer require qlimix/serializable
usage
<?php use Qlimix\Serializable\SerializableInterface; final class FooBar implements SerializableInterface { /** @var string */ private $foo; /** @var int */ private $bar; public function __construct(string $foo, int $bar) { $this->foo = $foo; $this->bar = $bar; } public function getName(): string { return 'foo.bar'; } public function serialize(): array { return [ 'foo' => $this->foo, 'bar' => $this->bar, ]; } public static function deserialize(array $data): SerializableInterface { return new self($data['foo'], $data['bar']); } }
If whatever you are serializing doesn't cross the boundaries of your application you could use the GetClassNameTrait to refer to the object class name.
Testing
To run all unit tests locally with PHPUnit:
$ vendor/bin/phpunit
Quality
To ensure code quality run grumphp which will run all tools:
$ vendor/bin/grumphp run
Contributing
Please see CONTRIBUTING for details.
统计信息
- 总下载量: 652
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-06-15