PHPackages                             softboxlab/php-collection-helper - 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. softboxlab/php-collection-helper

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

softboxlab/php-collection-helper
================================

Simple array and object-oriented collection

v0.0.1(8y ago)081MITPHP

Since Jun 15Pushed 8y agoCompare

[ Source](https://github.com/SoftboxLab/php-collection-helper)[ Packagist](https://packagist.org/packages/softboxlab/php-collection-helper)[ RSS](/packages/softboxlab-php-collection-helper/feed)WikiDiscussions master Synced 2d ago

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

[![Build Status](https://camo.githubusercontent.com/27c6cb251507da9b2beb9a75886bdc927d7ab7df0be9fdc964af7b94791e6445/68747470733a2f2f7472617669732d63692e6f72672f536f6674626f784c61622f7068702d636f6c6c656374696f6e2d68656c7065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SoftboxLab/php-collection-helper)[![codecov](https://camo.githubusercontent.com/78d6a0bb08a4d470865c99afa025417d5e170f72f4683306d079e5dcc318010a/68747470733a2f2f636f6465636f762e696f2f67682f536f6674626f784c61622f7068702d636f6c6c656374696f6e2d68656c7065722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/SoftboxLab/php-collection-helper)

Simple PHP Collection and array helper
======================================

[](#simple-php-collection-and-array-helper)

Simple collection class to work with arrays on object-oriented paradigm and some array (collection) helpers with standardization of the parameters (data first, callback later, like *javascript*).

Collection
----------

[](#collection)

In this definition, our collection is *Immutable*, which means that *every* operation should return a new collection, keeping the original collection intact.

```
$collection = new Collection([1, 2, 3, 4]);
$newCollection = $collection->map(function ($item) {
    return $item * 2;
});

print_r($newCollection->all()); // [2, 4, 6, 8]
print_r($collection->all()); // [1, 2, 3, 4]
```

Collection helper
-----------------

[](#collection-helper)

This is the base support to the Collection class. All the methods are implemented here.

### List of available methods

[](#list-of-available-methods)

- map($data, $callback ($value, $key));
    - Map all the items of data with the provided callback. The callback will receive both value's and key's of the array.
- filter($data, $callback($value, $key), $keepKeys);
    - Filter the given array with the provided callback. Only the items when the callback return's true will be returned on the filtered data. If false is passed to *keepKeys* parameter, the keys will be reseted.
- reduce($data, $callback($value, $key), $initialValue);
    - Reduce's the given data with the given callback.
- transform($data, $changes, $delimiter);
    - Transform the keys (change) of the given `$data` array with the `$changes` array. To navigate along the array, use the Laravel's dot syntax. If `$delimiter` provided, it changed the Laravel's dot syntax separator.
- transformArray($data, $changed, $delimiter);
    - Same as transform, but should be used on a list, which will apply on every item. Same as map with transform.

Transformer class
-----------------

[](#transformer-class)

Simple array transformer class, which convert all the keys by new ones. Something like a `from-to` where the all the keys of the given array will be replaced the by the value of the given replaced array when the key matches.

Example:

```
$transformer = new Transformer(['namae' => 'nombre']);
$data = ['namae' => 'William'];
$transformedData = $transformer->transform($data);

print_r($transformedData); // ['nombre' => 'William'];
```

Contributing
------------

[](#contributing)

Feel free to make any pull request you judge necessary!

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

3255d ago

### Community

Maintainers

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

---

Top Contributors

[![williamokano](https://avatars.githubusercontent.com/u/5909442?v=4)](https://github.com/williamokano "williamokano (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/softboxlab-php-collection-helper/health.svg)

```
[![Health](https://phpackages.com/badges/softboxlab-php-collection-helper/health.svg)](https://phpackages.com/packages/softboxlab-php-collection-helper)
```

###  Alternatives

[lbaey/chromedriver

Utility for installing Chromedriver, whatever platform you are on, for use with Behat

1459.5k1](/packages/lbaey-chromedriver)

PHPackages © 2026

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