PHPackages                             projx-io/fluent - 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. projx-io/fluent

ActiveLibrary

projx-io/fluent
===============

1.10.2(10y ago)132PHP

Since Feb 25Pushed 10y agoCompare

[ Source](https://github.com/projx-io/fluent)[ Packagist](https://packagist.org/packages/projx-io/fluent)[ RSS](/packages/projx-io-fluent/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (17)Used By (0)

[![Build Status](https://camo.githubusercontent.com/e6d52de25f93fa23a157b348aef516df1a7835268309e7fad15d8adbb102ab41/68747470733a2f2f7472617669732d63692e6f72672f70726f6a782d696f2f666c75656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/projx-io/fluent?branch=master)[![Coverage Status](https://camo.githubusercontent.com/726deb5125f671617d48a8e531851834c3fd5148c6b83dc9b3ffbf2ce5ab4931/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f70726f6a782d696f2f666c75656e742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/projx-io/fluent?branch=master)

Fluent
======

[](#fluent)

### Installation

[](#installation)

`composer require projx-io/fluent`

### Hello World

[](#hello-world)

```
// Requires two parameters.
function greet($greeting, $name) {
    return sprintf("%s, %s!\n", $greeting, $name);
}

// Creates a stream with 'World'.
// $stream is a stream node, which is a callable value.
// This particular node is a 'with' node, and will return
// the value 'World' when the stream is executed.
// If call() is called directly on this node, then 'World'
// will be the result. Otherwise, 'World' will be passed as
// a parameter to the next node.
$stream = Fluent('World');

// Creates a stream node whose callback is 'greet',
// and has a bound parameter of 'Hello'.
// 'Hello' will be provided as the first parameter to `greet`.
// In this particular stream, the value of 'World' returned
// from the previous node will be provided as the second
// parameter to this node.
$stream = $stream->then('greet', 'Hello');

// Executes the stream then prints the returned value of
// "Hello, World!"
echo $stream->call();
```

### Array Map Example

[](#array-map-example)

```
// adds two to a second parameter.
$offset = F::plus(2);
// results in 17
$offset->call(15);

// results in [3, 4, 5, 6, 7]
$items = F([1, 2, 3, 4, 5])
    ->map($offset)
    ->toArray();

```

### Array Filter Example

[](#array-filter-example)

```
// adds two to a parameter
$filter = F::plus(2)->moreThan(4);
// results in true, since 3+2 > 4 -> true
$filter->call(3);
// results in false, since 2+2 > 4 -> false
$filter->call(2);

// results in [3, 4, 5]
$items = F([1, 2, 3, 4, 5])
    ->filter($filter)
    ->toArray();

```

### Object Example

[](#object-example)

```
$stream = F::object([
    'name' => F()->name,            // get object's name
    'generation' => F::if(          // if/then/else
        F()->age->moreThan(21),     // condition of object's age being more than 21
        F('Old Geezer!'),           // when true
        F('Just a baby!')           // when false
    ),
]);

// Results in {"name":"Steve","generation":"Old Geezer!"}
$stream->call((object)['name'=>'Steve', 'age'=>32]);

// Results in {"name":"Stacey","generation":"Just a baby!"}
$stream->call((object)['name'=>'Stacey', 'age'=>20]);

```

### Array Example

[](#array-example)

```
$stream = F::map(
        F::plus(2)->times(-1)
    )[1]
    ->equalTo(-5);

// Results in true, since (3+2)*(-1) -> -5
$stream->call([2, 3, 4]);

// Results in false, since (-3+2)*(-1) -> 1
$stream->call([2, -3, 4]);

```

If you don't want to use a fluent stream, that's fine too.

### Callback example

[](#callback-example)

```
// Results in [4, 5, 6]
array_map(Plus::bind(2), [2, 3, 4]);

```

Registering Methods
-------------------

[](#registering-methods)

### Unbound

[](#unbound)

```
Fluent::registerMethods([
    'someMethod' => new ConstantCallbackFactory(function () {
        return ...
    }),
]);

Fluent::then(...)->someMethod();

```

### Bound

[](#bound)

```
Fluent::registerMethods([
    'someMethod' => new BindCallbackFactory(new ConstantCallbackFactory(function ($a, $b) {
        return ...
    })),
]);

Fluent::then(...)->someMethod($a, $b);

```

List of methods
---------------

[](#list-of-methods)

A list of methods can be found in the [Fluent](https://github.com/projx-io/fluent/blob/master/src/Fluent.php) class.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity71

Established project with proven stability

 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

16

Last Release

3726d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7814b5d7789e9fa5beab6710a3e98826394dc3e8b09a2dd2a5306d058062e5f2?d=identicon)[projx](/maintainers/projx)

---

Top Contributors

[![chemisus](https://avatars.githubusercontent.com/u/394062?v=4)](https://github.com/chemisus "chemisus (38 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/projx-io-fluent/health.svg)

```
[![Health](https://phpackages.com/badges/projx-io-fluent/health.svg)](https://phpackages.com/packages/projx-io-fluent)
```

PHPackages © 2026

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