PHPackages                             decodelabs/fluidity - 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. decodelabs/fluidity

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

decodelabs/fluidity
===================

Tools for creating fluent interfaces

v0.3.7(10mo ago)437.3k—0%1[1 issues](https://github.com/decodelabs/fluidity/issues)6MITPHPPHP ^8.4CI passing

Since Oct 6Pushed 5mo ago3 watchersCompare

[ Source](https://github.com/decodelabs/fluidity)[ Packagist](https://packagist.org/packages/decodelabs/fluidity)[ RSS](/packages/decodelabs-fluidity/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (15)Used By (6)

Fluidity
========

[](#fluidity)

[![PHP from Packagist](https://camo.githubusercontent.com/e07bf161a70f59048bb7a6d383b6d1ee9cfa7dec4349db6d8b8555a3ad314c8f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6465636f64656c6162732f666c7569646974793f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/fluidity)[![Latest Version](https://camo.githubusercontent.com/55faaf2c2be7ec80c2959e13217d3314ae743f45ca2387b9e77b63875a416585/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465636f64656c6162732f666c7569646974792e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/fluidity)[![Total Downloads](https://camo.githubusercontent.com/827e0b2c626eaa7dfe705e3c8a05de8d72ab5cc4e0aed01be3fd780f5756e228/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465636f64656c6162732f666c7569646974792e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/fluidity)[![GitHub Workflow Status](https://camo.githubusercontent.com/1204f01157b8aecc8683b9b4453e87d7eaf424a608b2568146da3426fc46ffd4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465636f64656c6162732f666c7569646974792f696e746567726174652e796d6c3f6272616e63683d646576656c6f70)](https://github.com/decodelabs/fluidity/actions/workflows/integrate.yml)[![PHPStan](https://camo.githubusercontent.com/e25c14ce011edabdd0fbd2e10415b41cc5d66ed11ef3e5b7edd074c5bdd35a2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d3434434331312e7376673f6c6f6e6743616368653d74727565267374796c653d666c6174)](https://github.com/phpstan/phpstan)[![License](https://camo.githubusercontent.com/e8fe0c3a969ff8b85218a797fc5ef44152c7b59d8b40decbc735659ac6c108ac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465636f64656c6162732f666c7569646974793f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/fluidity)

### Tools for creating fluent interfaces.

[](#tools-for-creating-fluent-interfaces)

Fluidity provides a set of middleware interfaces that aid in the development of libraries that themselves aim to provide fluid interfaces.

---

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

[](#installation)

This package requires PHP 8.4 or higher.

Install via Composer:

```
composer require decodelabs/fluidity
```

Usage
-----

[](#usage)

### Method chaining

[](#method-chaining)

```
namespace DecodeLabs\Fluidity;

interface Then
{
    public function then(callable $callback): Then;
    public function thenEach(iterable $values, callable $callback): Then;
    public function thenIf(?bool $truth, callable $yes, callable $no=null): Then;
    public function thenUnless(?bool $truth, callable $no, callable $yes=null): Then;
}
```

Create fluent object interfaces with basic generic logic structure support.

```
use DecodeLabs\Fluidity\Then;
use DecodeLabs\Fluidity\ThenTrait;

$test = new class() implements Then {
    use ThenTrait;

    public function doThing(int $value=null) {}
};

$truth = true;

$test
    ->then(function($test) {
        $test->doThing();
    })

    ->thenEach([1, 2, 3], function($test, $value) {
        // Called three times
        $test->doThing($value);
    })

    ->thenIf($truth, function($test) {
        // This gets called if($truth)
    }, function($test) {
        // This get called otherwise
    })

    ->thenUnless($truth, function($test) {
        // This gets called if(!$truth)
    }, function($test) {
        // This get called otherwise
    });
```

Licensing
---------

[](#licensing)

Fluidity is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance58

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 90.8% 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 ~145 days

Recently: every ~248 days

Total

13

Last Release

306d ago

PHP version history (5 changes)v0.1.0PHP ^7.2

v0.2.0PHP ^7.2|^8.0

v0.3.0PHP ^8.0

v0.3.5PHP ^8.1

v0.3.6PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a241d64d12b3b5ee94197862ec1ec30b82ed2efa34a0cd7f4c3565a021daddd?d=identicon)[betterthanclay](/maintainers/betterthanclay)

---

Top Contributors

[![betterthanclay](https://avatars.githubusercontent.com/u/1273586?v=4)](https://github.com/betterthanclay "betterthanclay (118 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (12 commits)")

---

Tags

fluid-interfacephplibraryfluenttoolsfluid

### Embed Badge

![Health badge](/badges/decodelabs-fluidity/health.svg)

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

###  Alternatives

[ph-7/qrcode-generator-php-class

Light QRCode PHP class (library). QR Code Generator using vCard 4.0 and the Google Chart AP

10415.5k2](/packages/ph-7-qrcode-generator-php-class)

PHPackages © 2026

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