PHPackages                             azjezz/input-hydrator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. azjezz/input-hydrator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

azjezz/input-hydrator
=====================

Hydrates input DTOs from request input.

1.0.1(5y ago)326801MITPHPPHP &gt;=7.4

Since Nov 1Pushed 5y ago2 watchersCompare

[ Source](https://github.com/azjezz/input-hydrator)[ Packagist](https://packagist.org/packages/azjezz/input-hydrator)[ RSS](/packages/azjezz-input-hydrator/feed)WikiDiscussions develop Synced 1w ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (1)

Input Hydrator
==============

[](#input-hydrator)

[![Unit tests status](https://github.com/azjezz/input-hydrator/workflows/unit%20tests/badge.svg?branch=develop)](https://github.com/azjezz/input-hydrator/workflows/unit%20tests/badge.svg?branch=develop)[![Static analysis status](https://github.com/azjezz/input-hydrator/workflows/static%20analysis/badge.svg?branch=develop)](https://github.com/azjezz/input-hydrator/workflows/static%20analysis/badge.svg?branch=develop)[![Security analysis status](https://github.com/azjezz/input-hydrator/workflows/security%20analysis/badge.svg?branch=develop)](https://github.com/azjezz/input-hydrator/workflows/security%20analysis/badge.svg?branch=develop)[![Coding standards status](https://github.com/azjezz/input-hydrator/workflows/coding%20standards/badge.svg?branch=develop)](https://github.com/azjezz/input-hydrator/workflows/coding%20standards/badge.svg?branch=develop)[![TravisCI Build Status](https://camo.githubusercontent.com/2c7b12b084f67e04ce5975fb6e607f02f6d835923076f113e3c5fe218551fc5f/68747470733a2f2f7472617669732d63692e636f6d2f617a6a657a7a2f696e7075742d6879647261746f722e7376673f6272616e63683d646576656c6f70)](https://travis-ci.com/azjezz/input-hydrator)[![Coverage Status](https://camo.githubusercontent.com/035086c17b1778f1c68141d381efdc51ed3d1bd4b01412c975cb83bc01e3d579/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f617a6a657a7a2f696e7075742d6879647261746f722f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/azjezz/input-hydrator?branch=develop)[![Type Coverage](https://camo.githubusercontent.com/918a2c73527ad78efdc4b2aa6dff35f7ce15a5dacdb57f99e1c79ce4de03b9c9/68747470733a2f2f73686570686572642e6465762f6769746875622f617a6a657a7a2f696e7075742d6879647261746f722f636f7665726167652e737667)](https://shepherd.dev/github/azjezz/input-hydrator)[![Mutation testing badge](https://camo.githubusercontent.com/9280ebf959dcd2f927fff1e93c6bc39fc1f42dd16ed3a94f222e1cf4e019cc80/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246617a6a657a7a253246696e7075742d6879647261746f72253246646576656c6f70)](https://dashboard.stryker-mutator.io/reports/github.com/azjezz/input-hydrator/develop)[![Total Downloads](https://camo.githubusercontent.com/cf83f3445361e8aae729a407f040efd5eeda03cc2c7f5c334b92004acb6ae449/68747470733a2f2f706f7365722e707567782e6f72672f617a6a657a7a2f696e7075742d6879647261746f722f642f746f74616c2e737667)](https://packagist.org/packages/azjezz/input-hydrator)[![Latest Stable Version](https://camo.githubusercontent.com/1463c54db779687b2b6e439fcc7422439a35893cd98dff6cc62da10f53358923/68747470733a2f2f706f7365722e707567782e6f72672f617a6a657a7a2f696e7075742d6879647261746f722f762f737461626c652e737667)](https://packagist.org/packages/azjezz/input-hydrator)[![License](https://camo.githubusercontent.com/ea5ff9989762f8b2d88c770d705d19695d16e0fa342acd406de36ded859175f0/68747470733a2f2f706f7365722e707567782e6f72672f617a6a657a7a2f696e7075742d6879647261746f722f6c6963656e73652e737667)](https://packagist.org/packages/azjezz/input-hydrator)

Input hydrator is a simple hydrator made for the sole purpose of hydrating data-transfer input objects.

Installation
------------

[](#installation)

```
$ composer require azjezz/input-hydrator
```

Example:
--------

[](#example)

```
use AzJezz\Input;

final class Search implements Input\InputInterface
{
    public string $query;
}

/**
 * @var Search $search
 */
$search = (new Input\Hydrator())->hydrate(Search::class, $_GET);

print $search->query;
```

While hydrating objects, some exceptions might be thrown:

- `AzJezz\Input\Exception\TypeException`: this exception should result in 500 HTTP status code, as it represents an issue within the input class itself. such as the usage of a non-supported type, or missing type for a specific property.
- `AzJezz\Input\Exception\BadInputException`: this exception should result in a 400 HTTP status code, as it means that the supplied request data doesn't match the input DTO structure.

Currently, Input-Hydrator is limited to a small set of types:

- `scalar` ( `string`, `int`, `float`, and `bool` )
- `null`
- *any object that implements `AzJezz\Input\InputInterface`*

Union types are supported for PHP &gt;= 8.0, for example:

```
use AzJezz\Input;

final class Filter implements Input\InputInterface
{
    public ?int $maximumPrice;
    public ?int $minimumPrice;
}

final class Search implements Input\InputInterface
{
    public string $query;
    public null|Filter|string $filter = null;
}

/**
 * $filter is optional, and is missing from the request, therefore it's gonna contain the default value.
 *
 * @var Search $search
 */
$search = (new Input\Hydrator())->hydrate(Search::class, [
  'query' => 'hello'
]);

/**
 * $search->filter is now an instance of `Filter`
 *
 * @var Search $search
 */
$search = (new Input\Hydrator())->hydrate(Search::class, [
  'query' => 'hello',
  'filter' => [
    'maximum_price' => 1000,
    'minimum_price' => 10, // the field is optional ( nullable ), so we can remove this line.
  ]
]);

/**
 * $search->filter is now a string
 *
 * @var Search $search
 */
$search = (new Input\Hydrator())->hydrate(Search::class, [
  'query' => 'hello',
   // this is okay as the `null|Filter|string` union contains `string`
  'filter' => 'maximum_price=1000&minimum_price=10',
]);

print $search->query;
```

License
-------

[](#license)

The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2024d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8489d7c85bfa7c637b8e13484f3f659652aea0568b6e7f9e66edeb0649b5a2f1?d=identicon)[azjezz](/maintainers/azjezz)

---

Top Contributors

[![azjezz](https://avatars.githubusercontent.com/u/29315886?v=4)](https://github.com/azjezz "azjezz (16 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/azjezz-input-hydrator/health.svg)

```
[![Health](https://phpackages.com/badges/azjezz-input-hydrator/health.svg)](https://phpackages.com/packages/azjezz-input-hydrator)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
