innmind/reflection
最新稳定版本:5.2.0
Composer 安装命令:
composer require innmind/reflection
包简介
Library to build objects and extract data out of them
关键字:
README 文档
README
Library to build objects and extract data out of them.
Build and inject data into an object
use Innmind\Reflection\Instanciate; use Innmind\Immutable\{ Map, Maybe, }; final class Foo { private int $foo; private mixed $bar; public function __construct(string $foo) { $this->foo = $foo; } } $object = (new Instanciate)(Foo::class, Map::of( ['foo', 42], ['bar', 'baz'], )); // Maybe<Foo>
This code will create a new Foo object and assign the property foo to 42 and bar to 'baz'.
Extracting data out of an object
use Innmind\Reflection\Extract; use Innmind\Immutable\{ Set, Maybe, Map, }; $properties = (new Extract)($myObject, Set::of('foo', 'bar', 'baz')); // Maybe<Map<non-empty-string, mixed>>
统计信息
- 总下载量: 20.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-28