pew-pew / hydrator-jms
JMS serializer hydrator bridge
Installs: 1 090
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.3
- doctrine/instantiator: ^1.5|^2.0
- jms/serializer: ^3.0
- pew-pew/hydrator: ^0.1|^1.0
- psr/cache: ^1.0|^2.0|^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.49
- phpunit/phpunit: ^10.5
- symfony/var-dumper: ^5.4|^6.0|^7.0
- vimeo/psalm: ^5.21
This package is auto-updated.
Last update: 2024-10-26 23:33:52 UTC
README
JMS Hydrator Bridge
A set of interfaces for mapping arbitrary values to their typed equivalents and their inverses using the JMS (jms/serializer) package.
Installation
PewPew JMS Hydrator is available as Composer repository and can be installed using the following command in a root of your project:
$ composer require pew-pew/hydrator-jms
More detailed installation instructions are here.
Usage
Simple hydrator creation:
$jms = PewPew\Hydrator\JMS\Builder::create();
Hydrator
$hydrator = PewPew\Hydrator\JMS\Builder::create() ->createHydrator(); $dto = $hydrator->hydrate(ExampleDTO::class, [ 'id' => 42, 'name' => 'Vasya', ]); // object(ExampleDTO) { // id: int(42), // name: string("Vasya"), // }
Extractor
$extractor = PewPew\Hydrator\JMS\Builder::create() ->createExtractor(); $data = $extractor->extract(new ExampleDTO( id: 42, name: 'Vasya', )); // array(2) [ // id => int(42), // name => string("Vasya"), // ]