Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pew-pew-team/hydrator

Hydrator kernel component
https://github.com/pew-pew-team/hydrator

data deserializer dto hydrator kernel mapper mapping serializer structure

Last synced: about 1 month ago
JSON representation

Hydrator kernel component

Awesome Lists containing this project

README

        




PHP 8.3+
Latest Stable Version
Latest Unstable Version
License MIT







# Hydrator

A set of interfaces for mapping arbitrary values to their typed equivalents
and their inverses.

## Installation

PewPew Hydrator is available as Composer repository and can be installed using
the following command in a root of your project:

```bash
$ composer require pew-pew/hydrator
```

More detailed installation [instructions are here](https://getcomposer.org/doc/01-basic-usage.md).

## Usage

```php
$hydrator = new class implements \PewPew\Hydrator\HydratorInterface {
public function hydrate(string $type, mixed $data): mixed
{
return ...;
}
};

$hydrator = new \PewPew\Hydrator\TraceableHydrator(
hydrator: $hydrator,
stopwatch: new \Symfony\Component\Stopwatch\Stopwatch(),
);

$hydrator = new \PewPew\Hydrator\LoggableHydrator(
hydrator: $hydrator,
logger: new ExampleLogger(),
);
```