PHPackages                             babenkoivan/fluent-array - 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. babenkoivan/fluent-array

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

babenkoivan/fluent-array
========================

The package provides fluent interface for array management

v1.0.0(7y ago)558MITPHPPHP ^7.0

Since Jul 9Pushed 7y agoCompare

[ Source](https://github.com/babenkoivan/fluent-array)[ Packagist](https://packagist.org/packages/babenkoivan/fluent-array)[ RSS](/packages/babenkoivan-fluent-array/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

FluentArray
===========

[](#fluentarray)

[![Packagist](https://camo.githubusercontent.com/abccec1595da4f4f8c238c18825f776dd03e55c0aac84e7e28cce38becf0dcad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626162656e6b6f6976616e2f666c75656e742d61727261792e737667)](https://packagist.org/packages/babenkoivan/fluent-array)[![Packagist](https://camo.githubusercontent.com/ff713a2abe79e8531004129ef8b52014c79fb9e81cefc897b2b979aa820cbaa3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626162656e6b6f6976616e2f666c75656e742d61727261792e737667)](https://packagist.org/packages/babenkoivan/fluent-array)[![Build Status](https://camo.githubusercontent.com/b457d5143c7052b1a274018dc9ce6ce533465c42eb9140e606b4ddc5040e7a85/68747470733a2f2f7472617669732d63692e636f6d2f626162656e6b6f6976616e2f666c75656e742d61727261792e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/babenkoivan/fluent-array)[![license](https://camo.githubusercontent.com/850eae1099d2b05f53383473d7cd51f9bc1ab09b7d0d9e5122f1dd930efdcc6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e737667)](https://packagist.org/packages/babenkoivan/fluent-array)[![Donate](https://camo.githubusercontent.com/ae330d33706db436cdd131659cf5dec4f9468fadd5bec2f270a775b4f2c4b658/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d50617950616c2d626c75652e737667)](https://www.paypal.me/ivanbabenko)

- [Introduction](#introduction)
- [Installation](#installation)
- [Configuration](#configuration)
- [Macros](#macros)
- [Fixed methods](#fixed-methods)
- [Dynamic methods](#dynamic-methods)
- [Implemented interfaces](#implemented-interfaces)
- [Code Formatting](#code-formatting)

Introduction
------------

[](#introduction)

The fluent array library provides you with a convenient chainable interface. If you like object-oriented syntax or you just want to have more readable array declaration, the fluent array is at your service.

#### Basic usage

[](#basic-usage)

```
$order = (new FluentArray())
    ->user()
        ->id(1)
        ->name('John')
    ->end()
    ->coupon('SALE10')
    ->status('delivered')
    ->products()
        ->push()
            ->id(1)
            ->name('iPhone X')
            ->price(1200)
        ->end()
        ->push()
            ->id(2)
            ->name('Beats By Dre Studio3')
            ->price(360)
        ->end()
    ->end();
```

If we convert the fluent array to an associative array, by calling `$order->toArray()`, we will get the following output:

```
[
    'user' => [
        'id' => 1,
        'name' => 'John'
    ],
    'coupon' => 'SALE10',
    'status' => 'delivered',
    'products' => [
        [
            'id' => 1,
            'name' => 'iPhone X',
            'price' => 1200
        ],
        [
            'id' => 2,
            'name' => 'Beats By Dre Studio3'
            'price' => 360
        ]
    ]
]
```

#### Storage array

[](#storage-array)

Every time you call [set](#set) or [get]($get), or any other method, that modifies or retrieves the state, you update the internal storage of fluent array.

```
$fluentArray = new FluentArray();

// we set the key `one` and the corresponding value `1` in the storage
$fluentArray->set('one', 1);

// we get the value, that corresponds the key `one` from the storage
$fluentArray->get('one');
```

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

[](#installation)

Use composer to install the library:

```
composer require babenkoivan/fluent-array
```

Configuration
-------------

[](#configuration)

The configuration allows you to change a fluent array [behavior](#naming-strategies) and add [new functionality](#macros).

#### Local scope

[](#local-scope)

To configure a specific fluent array instance use local scope.

```
$config = (clone FluentArray::globalConfig())
    ->namingStrategy(new CamelCaseStrategy());

$fluentArray = (new FluentArray($config))
    ->one(1)
    ->two(2);

// alternatively you can set configuration, using the `config` method
$fluentArray = (new FluentArray())
    ->config($config)
    ->one(1)
    ->two(2);

$fluentArray->all();
// ['One' => 1, 'Two' => 2]
```

#### Global scope

[](#global-scope)

To configure all fluent arrays use global scope.

```
$globalConfig = FluentArray::globalConfig();

$globalConfig->namingStrategy(new CamelCaseStrategy());

$fluentArray = (new FluentArray())
    ->one(1)
    ->two(2);

$fluentArray->all();
// ['One' => 1, 'Two' => 2]
```

#### Macros

[](#macros)

You can use macros to extend a fluent array functionality. It can be done via configuration in [global](#global-scope) or [local scope](#local-scope).

```
$globalConfig = FluentArray::globalConfig();

$globalConfig
    ->macros()
        ->format(function (string $key, int $decimals = 0) {
            $value = $this->get($key);

            if (is_numeric($value)) {
                return number_format($value, $decimals);
            } else {
                return $value;
            }
        })
    ->end();

$fluentArray = (new FluentArray())
    ->set('one', 10.567)
    ->set('two', 2.89);

$fluentArray->format('one', 2);
// 10.57

$fluentArray->format('two', 1);
// 2.9
```

#### Naming strategies

[](#naming-strategies)

Naming strategies describe key transformation in [dynamic methods](#dynamic-methods).

For example, we want all our keys to be underscored in [the storage array](#storage-array).

```
$config = (clone FluentArray::globalConfig())
    ->namingStrategy(new UnderscoreStrategy());

$fluentArray = (new FluentArray($config))
    ->firstValue(1)
    ->secondValue(2);

$fluentArray->all();
// ['first_value' => 1, 'second_value' => 2]
```

Now we want them to be camel-cased.

```
$config = (clone FluentArray::globalConfig())
    ->namingStrategy(new CamelCaseStrategy());

$fluentArray = (new FluentArray($config))
    ->firstValue(1)
    ->secondValue(2);

$fluentArray->all();
// ['first_value' => 1, 'second_value' => 2]
```

The supported naming strategies are:

StrategyExampleCamelCaseStrategy`MyValue`NullStrategy`myValue`UnderscoreStrategy`my_value`The default naming strategy is `UnderscoreStrategy`.

Fixed methods
-------------

[](#fixed-methods)

- [all](#all)
- [clean](#clean)
- [config](#config)
- [count](#count)
- [each](#each)
- [filter](#filter)
- [first](#first)
- [fromArray](#fromarray)
- [fromJson](#fromjson)
- [get](#get)
- [globalConfig](#globalconfig)
- [has](#has)
- [keys](#keys)
- [krsort](#krsort)
- [ksort](#ksort)
- [last](#last)
- [map](#map)
- [pluck](#pluck)
- [pushWhen](#pushwhen)
- [push](#push)
- [rsort](#rsort)
- [setWhen](#setwhen)
- [set](#set)
- [sort](#sort)
- [toArray](#toarray)
- [toJson](#tojson)
- [unset](#unset)
- [usort](#usort)
- [values](#values)
- [when](#when)

#### all

[](#all)

The `all` method returns [the storage array](#storage-array).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->all();
// ['one' => 1, 'two' => 2]
```

#### clean

[](#clean)

The `clean` method removes all keys and values from [the storage array](#storage-array).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->all();
// ['one' => 1, 'two' => 2]

$fluentArray->clean()->all();
// []
```

#### config

[](#config)

The `config` method allows you to set or retrieve [local configuration](#local-scope).

```
$config = (new FluentArray())
    ->set('naming_strategy', new NullStrategy());

$fluentArray = (new FluentArray())
    ->config($config);

$fluentArray->config()->get('naming_strategy');
// instance of NullStrategy
```

#### count

[](#count)

The `count` method returns the amount of values in [the storage array](#storage-array).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2)
    ->set('three', 3);

$fluentArray->count();
// 3
```

#### each

[](#each)

The `each` method iterates over the values in [the storage array](#storage-array).

```
$odds = [];

$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2)
    ->set('three', 3)
    ->set('four', 4);

$fluentArray->each(function ($value, $key) use (&$odds) {
    if ($value % 2 !== 0) {
        $odds[] = $value;
    }
});

$odds;
// [1, 3]
```

To stop the iteration return `false` from the callback.

```
$counter = 0;

$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2)
    ->set('three', 3);

$fluentArray->each(function ($value, $key) use (&$counter) {
    if ($value > 1) {
        return false;
    }

    $counter++;
});

$counter;
// 1
```

#### filter

[](#filter)

The `filter` method filters [the storage array](#storage-array) using the given callback. Return `false` from the callback to remove a value.

```
$sourceFluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$filteredFluentArray = $sourceFluentArray->filter(function ($value, $key) {
    return $value > 1;
});

$filteredFluentArray->all();
// ['two' => 2]
```

If callback is not specified, all values, that can be converted to `false` will be removed.

```
$fluentArray = (new FluentArray())
    ->set('zero', 0)
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->filter()->all();
// ['one' => 1, 'two' => 2]
```

#### first

[](#first)

The `first` method retrieves the first value from [the storage array](#storage-array).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->first();
// 1
```

#### fromArray

[](#fromarray)

The `fromArray` method converts an array to a fluent array.

```
$array = ['one' => 1, 'two' => 2];

$fluentArray = FluentArray::fromArray($array);

$fluentArray->all();
// ['one' => 1, 'two' => 2]
```

#### fromJson

[](#fromjson)

The `fromJson` method converts JSON to a fluent array.

```
$json = '{"one":1,"two":2}';

$fluentArray = FluentArray::fromJson($json);

$fluentArray->all();
// ['one' => 1, 'two' => 2]
```

#### get

[](#get)

The `get` method retrieves the value from [the storage array](#storage-array), that corresponds the given key.

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->get('two');
// 2
```

#### globalConfig

[](#globalconfig)

The `globalConfig` method allows you to set or retrieve [global configuration](#global-scope).

```
$globalConfig = (new FluentArray())
    ->set('naming_strategy', new NullStrategy());

FluentArray::globalConfig($globalConfig);

FluentArray::globalConfig()->get('naming_strategy');
// instance of NullStrategy
```

#### has

[](#has)

The `has` method checks if the given key exists in [the storage array](#storage-array).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->has('one');
// true

$fluentArray->has('three');
// false
```

#### keys

[](#keys)

The `keys` method retrieves all the keys from [the storage array](#storage-array).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->keys();
// ['one', 'two']
```

#### krsort

[](#krsort)

The `krsort` method sorts [the storage array](#storage-array) by keys in descending order. You can specify sort flags as a first argument.

```
$fluentArray = (new FluentArray())
    ->set('b', 1)
    ->set('a', 2)
    ->set('c', 3);

$fluentArray->krsort(SORT_STRING)->all();
// ['c' => 3, 'b' => 1, 'a' => 2]
```

#### ksort

[](#ksort)

The `ksort` method sorts [the storage array](#storage-array) by keys in ascending order. You can specify sort flags as a first parameter.

```
$fluentArray = (new FluentArray())
    ->set('b', 1)
    ->set('a', 2)
    ->set('c', 3);

$fluentArray->ksort(SORT_STRING)->all();
// ['a' => 2, 'b' => 1, 'c' => 3]
```

#### last

[](#last)

The `last` method retrieves the last value from [the storage array](#storage-array).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->last();
// 2
```

#### map

[](#map)

The `map` method applies the given callback to all values in [the storage array](#storage-array)and returns a new fluent array.

```
$sourceFluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$resultFluentArray = $sourceFluentArray->map(function ($value, $key) {
    return $value * 10;
});

$resultFluentArray->all();
// ['one' => 10, 'two' => 20]
```

#### pluck

[](#pluck)

The `pluck` method extracts values with the given key, from child fluent arrays to a new fluent array.

```
$fluentArray = (new FluentArray())
    ->set('one', (new FluentArray())->set('id', 1))
    ->set('two', (new FluentArray())->set('id', 2));

$fluentArray->pluck('id')->all();
// [1, 2]
```

#### push

[](#push)

The `push` method appends the given value to [the storage array](#storage-array).

```
$fluentArray = (new FluentArray())
    ->push(1)
    ->push(2);

$fluentArray->all();
// [1, 2]
```

Another way of using the `push` method:

```
$fluentArray = (new FluentArray())
    ->push()
        ->one(1)
        ->two(2)
    ->end()
    ->push()
        ->three(3)
    ->end();

$fluentArray->toArray();
// [['one' => 1, 'two' => 2], ['three' => 3]]
```

#### pushWhen

[](#pushwhen)

The `pushWhen` method appends the given value to [the storage array](#storage-array), if the first argument is equivalent to `true`.

```
$fluentArray = (new FluentArray())
    ->pushWhen(true, 1)
    ->pushWhen(false, 2)
    ->pushWhen(function () { return true; }, 3);

$fluentArray->all();
// [1, 3]
```

Another way of using the `pushWhen` method:

```
$fluentArray = (new FluentArray())
    ->pushWhen(true)
        ->one(1)
    ->end(false)
    ->pushWhen(false)
        ->two(2)
    ->end()
    ->pushWhen(function () { return true; })
        ->three(3)
    ->end();

$fluentArray->toArray();
// [['one' => 1], ['three' => 3]]
```

#### rsort

[](#rsort)

The `rsort` method sorts [the storage array](#storage-array) in descending order. You can specify sort flags as a first parameter.

```
$fluentArray = (new FluentArray())
    ->set('three', 3)
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->rsort(SORT_NUMERIC)->all();
// ['three' => 3, 'two' => 2, 'one' => 1]
```

#### set

[](#set)

The `set` method sets the given key and value in [the storage array](#storage-array).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->all();
// ['one' => 1, 'two' => 2]
```

#### setWhen

[](#setwhen)

The `setWhen` method sets the given key and value in [the storage array](#storage-array), if the first argument is equivalent to `true`.

```
$fluentArray = (new FluentArray())
    ->setWhen(true, 'one', 1)
    ->setWhen(false, 'two', 2)
    ->setWhen(function () { return true; }, 'three', 3);

$fluentArray->all();
// ['one' => 1, 'three' => 3]
```

#### sort

[](#sort)

The `sort` method sorts [the storage array](#storage-array) in ascending order. You can specify sort flags as a first parameter.

```
$fluentArray = (new FluentArray())
    ->set('three', 3)
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->sort(SORT_NUMERIC)->all();
// ['one' => 1, 'two' => 2, 'three' => 3]
```

#### toArray

[](#toarray)

The `toArray` method converts a fluent array to an array.

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->toArray();
// ['one' => 1, 'two' => 2]
```

#### toJson

[](#tojson)

The `toJson` method converts a fluent array to JSON.

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->toJson();
// "{"one":1,"two":2}"
```

#### unset

[](#unset)

The `unset` method removes [the storage array](#storage-array) value by the given key.

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->unset('one')->all();
// ['two' => 2]
```

#### usort

[](#usort)

The `usort` method sorts [the storage array](#storage-array) using the given comparison function.

```
$fluentArray = (new FluentArray())
    ->set('three', 3)
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->usort(function ($a, $b) {
    return $a  $b;
});

$fluentArray->all();
// ['one' => 1, 'two' => 2, 'three' => 3]
```

#### values

[](#values)

The `values` method retrieves all the values from [the storage array](#storage-array).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$fluentArray->all();
// [1, 2]
```

#### when

[](#when)

The `when` method executes the given callback, if the first argument is equivalent to `true`.

```
$fluentArray = new FluentArray();

$fluentArray->when(true, function () use ($fluentArray) {
    $fluentArray->set('one', 1);
});

$fluentArray->when(false, function () use ($fluentArray) {
    $fluentArray->set('two', 2);
});

$fluentArray->when(
    function () {
        return true;
    },
    function () use ($fluentArray) {
        $fluentArray->set('three', 3);
    }
);

$fluentArray->all();
// ['one' => 1, 'three' => 3]
```

You can specify a default callback, that will be executed, if the first argument is equivalent to `false`.

```
$fluentArray = new FluentArray();

$fluentArray->when(
    false,
    function () use ($fluentArray) {
        $fluentArray->set('one', 1);
    },
    function () use ($fluentArray) {
        $fluentArray->set('two', 2);
    }
);

$fluentArray->all();
// ['two' => 2]
```

Dynamic methods
---------------

[](#dynamic-methods)

- [Dynamic setter](#dynamic-setter)
- [Dynamic getter](#dynamic-getter)
- [Dynamic has](#dynamic-has)
- [Dynamic pluck](#dynamic-pluck)
- [Dynamic unset](#dynamic-unset)

#### Dynamic setter

[](#dynamic-setter)

You can also set a key-value pair in [the storage array](#storage-array) using a dynamic setter.

```
$fluentArray = (new FluentArray())
    ->one(1)
    ->two(2);

$fluentArray->all();
// ['one' => 1, 'two' => 2]
```

If you want to set the key, that is reserved for a method name, you can escape it.

```
$fluentArray = (new FluentArray())
    ->{'\set'}(1)
    ->{'\get'}(2);

$fluentArray->all();
// ['set' => 1, 'get' => 2]
```

Add `When` to set the given value if the first argument is equivalent to `true`.

```
$fluentArray = (new FluentArray())
    ->oneWhen(true, 1)
    ->twoWhen(false, 2)
    ->threeWhen(function () { return true; }, 3);

$fluentArray->all();
// ['one' => 1, 'three' => 3]
```

You can also chain creation of child fluent arrays.

```
$fluentArray = (new FluentArray())
    ->one()
        ->two(3)
    ->end()
    ->three()
        ->four(4)
        ->five(5)
    ->end();

$fluentArray->toArray();
// ['one' => ['two' => 2], 'three' => ['four' => 4, 'five' => 5]]
```

#### Dynamic getter

[](#dynamic-getter)

To retrieve a value from [the storage array](#storage-array) you can use a dynamic getter.

```
$fluentArray = (new FluentArray())
    ->one(1)
    ->two(2);

$fluentArray->two();
// 2
```

#### Dynamic has

[](#dynamic-has)

To check if a key exists in [the storage array](#storage-array) you can use a dynamic `has` method.

```
$fluentArray = (new FluentArray())
    ->one(1)
    ->two(2);

$fluentArray->hasOne();
// true

$fluentArray->hasThree();
// false
```

#### Dynamic pluck

[](#dynamic-pluck)

To extract values from child fluent arrays you can use a dynamic `pluck` method.

```
$fluentArray = (new FluentArray())
    ->one()
        ->id(1)
    ->end()
    ->two()
        ->id(2)
    ->end();

$fluentArray->pluckId()->all();
// [1, 2]
```

#### Dynamic unset

[](#dynamic-unset)

To remove a value from [the storage array](#storage-array) you can use a dynamic `unset` method.

```
$fluentArray = (new FluentArray())
    ->one(1)
    ->two(2);

$fluentArray->unsetOne()->all();
// ['two' => 2]
```

Implemented interfaces
----------------------

[](#implemented-interfaces)

- [Countable](#countable)
- [Serializable](#serializable)
- [ArrayAccess](#arrayaccess)
- [IteratorAggregate](#iteratoraggregate)

#### Countable

[](#countable)

The `Countable` interface provides the `count` method support. [See more here](http://php.net/manual/en/class.countable.php).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

count($fluentArray);
// 2
```

#### Serializable

[](#serializable)

The `Serializable` interface provides serialization support. [See more here](http://php.net/manual/en/class.serializable.php).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

$serialized = serialize($fluentArray);
$unserialized = unserialize($serialized);

$unserialized->all();
// ['one' => 1, 'two' => 2]
```

#### ArrayAccess

[](#arrayaccess)

The `ArrayAccess` interface provides array access. [See more here](http://php.net/manual/en/class.arrayaccess.php).

```
$fluentArray = new FluentArray();

$fluentArray['one'] = 1;
$fluentArray['two'] = 2;

$fluentArray['two'];
// 2
```

#### IteratorAggregate

[](#iteratoraggregate)

The `IteratorAggregate` interface enables iteration over [the storage array](#storage-array). [See more here](http://php.net/manual/en/class.iteratoraggregate.php).

```
$fluentArray = (new FluentArray())
    ->set('one', 1)
    ->set('two', 2);

foreach ($fluentArray as $key => $value) {
    $fluentArray->set($key, $value * 10);
}

$fluentArray->all();
// ['one' => 10, 'two' => 20]
```

Code formatting
---------------

[](#code-formatting)

If you use `PhpStorm` and code auto formatting, you will likely face the issue, that the following code:

```
$fluentArray = (new FluentArray())
    ->one()
        ->id(1)
    ->end()
    ->two()
        ->id(2)
    ->end();
```

Will be transformed by `PhpStorm` to:

```
$fluentArray = (new FluentArray())
    ->one()
    ->id(1)
    ->end()
    ->two()
    ->id(2)
    ->end();
```

Now the code is less readable, but luckily we can configure `PhpStorm` to disable auto formatting the specified peace of code. To do so, open `PhpStorm` preferences, go to the `Editor > Code Style` section and select option `Enable formatter markers in comments`.

Now you can turn the formatter off for the specific part of your code:

```
// @formatter:off
$fluentArray = (new FluentArray())
    ->one()
        ->id(1)
    ->end()
    ->two()
        ->id(2)
    ->end();
// @formatter:on
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

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 ~50 days

Total

4

Last Release

2714d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e8985eaa8cad12914027a7a3d9ca32d2cfc6f382f6429f2d4d3e65512dc0581?d=identicon)[babenkoivan](/maintainers/babenkoivan)

---

Top Contributors

[![babenkoivan](https://avatars.githubusercontent.com/u/25812954?v=4)](https://github.com/babenkoivan "babenkoivan (22 commits)")

---

Tags

arrayarray-helperarray-objectassociative-arraychainablefluent-interfacearrayArray objectchainablefluent-interfacearray helperassociative array

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/babenkoivan-fluent-array/health.svg)

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

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k411.1M1.2k](/packages/doctrine-collections)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[league/config

Define configuration arrays with strict schemas and access values with dot notation

564302.2M24](/packages/league-config)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[openlss/lib-array2xml

Array2XML conversion library credit to lalit.org

31052.5M47](/packages/openlss-lib-array2xml)

PHPackages © 2026

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