chanshige / object-hydrator
An ObjectHydrator that array to object to array conversion
v2.3.0
2022-10-18 05:30 UTC
Requires
- php: >=8.1
- symfony/property-access: ^6.0
- symfony/serializer: ^6.0
Requires (Dev)
- phpmd/phpmd: ^2.9
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-10-18 10:04:34 UTC
README
An ObjectHydrator that array to object to array conversion. It internally uses Symfony/Serializer (with ObjectNormalizer).
- オブジェクトから配列への変換
- 配列のデータを、特定のオブジェクトにセット
installation
With Composer
$ composer require chanshige/object-hydrator 'v1.0'
Usage
/** @var ObjectHydratorInterface $hydrator */
$hydrator = (new ObjectHydratorFactory())->newInstance();
### Put data from an array into an object. ###
/** @var Example $object */
$object = $hydrator->hydrate(array or stdClass, Example::class);
### Convert object to array. ###
/** @var array */
$array = $hydrator->extract($object);
Test
$ composer test
Contributing
Feel free to create issues and submit pull requests. For any PR submitted, make sure it is covered by tests or include new tests.
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
License
MIT