PHPackages                             battis/hydratable - 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. battis/hydratable

ActiveLibrary

battis/hydratable
=================

Hydrate serialized objects with defaults and overrides

v0.1.1(2y ago)06522GPL-3.0PHPPHP &gt;=7.3CI failing

Since Nov 24Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/battis/hydratable)[ Packagist](https://packagist.org/packages/battis/hydratable)[ RSS](/packages/battis-hydratable/feed)WikiDiscussions main Synced 6d ago

READMEChangelogDependenciesVersions (3)Used By (2)

Hydratable
==========

[](#hydratable)

[![Latest Version](https://camo.githubusercontent.com/4ab5401c9cc5f2186ec8ce41d37a2be2c7beac4ec30d753463acc4129898ee1a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6261747469732f68796472617461626c652e737667)](https://packagist.org/packages/battis/hydratable)[![codecov](https://camo.githubusercontent.com/462386f14fa5299777cbc76dcf601efb470c1584871d7d61e722626481cc3504/68747470733a2f2f636f6465636f762e696f2f67682f6261747469732f68796472617461626c652f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d42473656424b434e4642)](https://codecov.io/gh/battis/hydratable)

Hydrate serialized objects with defaults and overrides

This is meant to make it easier to take [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) arguments and hydrate them based on preset defaults.

Install
-------

[](#install)

```
composer require battis/hydratable
```

Use
---

[](#use)

This can either be added as a trait to a class or as an invokable class.

```
use Battis\Hydratable\Hydratable;

class MyObject
{
    use Hydratable;

    private static $DEFAULTS = [
      'foo' => 'bar',
      'argle' => 'bargle'
    ]

    private $options;

    public function __construct(array $params = [])
    {
        $this->options = $this->hydrate($params, self::$DEFAULTS);
    }
}
```

One could then instantiate an instance of `MyObject`:

```
$o = new MyObject(['baz' => 123, 'argle' = 'BaRgLe']);

/*
$o->options = [
    'foo' => 'bar',
    'baz' => 123,
    'argle' => 'BaRgLe'
]
*/
```

Alternatively, we could simply instantiate `Hydrate` and use it as a one-off:

```
$hydrate = new Battis\Hydratable\Hydrate();
$options = $hydrate($params, $defaults);
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance52

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 85.2% 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 ~222 days

Total

2

Last Release

1047d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d0554a28104c65004c6de4d335ada25cf2763c8a9691dc5611314486d461fa4c?d=identicon)[battis](/maintainers/battis)

---

Top Contributors

[![battis](https://avatars.githubusercontent.com/u/419619?v=4)](https://github.com/battis "battis (23 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")

### Embed Badge

![Health badge](/badges/battis-hydratable/health.svg)

```
[![Health](https://phpackages.com/badges/battis-hydratable/health.svg)](https://phpackages.com/packages/battis-hydratable)
```

PHPackages © 2026

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