PHPackages                             arandu/reducible - 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. arandu/reducible

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

arandu/reducible
================

Reducible pattern as a trait

v1.0.0(2y ago)0994↓50%3MITPHPPHP ^8.1

Since Mar 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/AranduTech/php-reducible)[ Packagist](https://packagist.org/packages/arandu/reducible)[ RSS](/packages/arandu-reducible/feed)WikiDiscussions main Synced 1mo ago

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

Reducible Trait
===============

[](#reducible-trait)

[![Tests](https://github.com/AranduTech/php-reducible/actions/workflows/test.yml/badge.svg)](https://github.com/AranduTech/php-reducible/actions/workflows/test.yml)

A trait to make your classes customizable via a set of reducers.

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

[](#installation)

```
composer require arandu/reducible
```

Usage
-----

[](#usage)

```
use Arandu\Reducible\Reducible;

class MyClass
{
    use Reducible;

    public function callApi($url, $options)
    {
        // will call all reducers for the method name
        $options = $this->transformCallApiOptions($options);

        // ...
    }
}

// -----

// Register a 'transformCallApiOptions' reducer
MyClass::reducer('transformCallApiOptions', function ($options) {
    return [
        ...$options,
        'headers' => [
            ...($options['headers'] ?? []),
            'Authorization' => 'Bearer ' . $this->token,
        ],
    ];
});

// Multiple reducers can be added
MyClass::reducer('transformCallApiOptions', function ($options) {
    return [
        ...$options,
        'headers' => [
            ...($options['headers'] ?? []),
            'X-Api-Key' => $this->apiKey,
        ],
    ];
});

// -----

$myClass = new MyClass();

$myClass->callApi('https://api.example.com', [
    'headers' => [
        'Content-Type' => 'application/json',
    ],
]);
// The callApi method will be called with the following options:
// [
//     'headers' => [
//         'Content-Type' => 'application/json',
//         'Authorization' => 'Bearer ' . $myClass->token,
//         'X-Api-Key' => $myClass->apiKey,
//     ],
// ]
```

Advanced Usage
--------------

[](#advanced-usage)

Read the [Advanced Usage](docs/advanced-usage.md) documentation.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

Testing
-------

[](#testing)

```
composer test
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity51

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

802d ago

Major Versions

v0.0.1 → v1.0.02024-03-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/84a3afb785274d1c4712e7ed9fd924fe5dfd1f0c033e051f9d07d55df565920a?d=identicon)[obrunopolo](/maintainers/obrunopolo)

---

Top Contributors

[![obrunopolo](https://avatars.githubusercontent.com/u/47830258?v=4)](https://github.com/obrunopolo "obrunopolo (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/arandu-reducible/health.svg)

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

###  Alternatives

[blanchonvincent/super-messenger

ZF2 module v1.0.1 - Boost your FlashMessenger !

151.6k](/packages/blanchonvincent-super-messenger)

PHPackages © 2026

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