PHPackages                             rubicon/collection - 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. rubicon/collection

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

rubicon/collection
==================

1.3.5(10y ago)035.0k↓66.8%PHPPHP &gt;=5.5

Since Aug 5Pushed 10y ago1 watchersCompare

[ Source](https://github.com/ronan-gloo/collection)[ Packagist](https://packagist.org/packages/rubicon/collection)[ RSS](/packages/rubicon-collection/feed)WikiDiscussions master Synced 2d ago

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

Collection Library
==================

[](#collection-library)

### Searching

[](#searching)

```
$collection = new Collection(['one', 'two']);

// search by element: true
$collection->contains('one');

// search by key: true
$collection->has(1);

// find the first index of the given element.
$collection->indexOf('one');

// get a Collection instance for all indexes of the given element
$collection->indexesOf('one');

```

### Map | Reduce

[](#map--reduce)

The method reduce() can return any kind of value.

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

echo $result; // 12

```

### Filter / Reject

[](#filter--reject)

Filter accepts any valid callback

```
// creates new collection with only string elements found in $collection
$filtered = $collection->filter('is_string');

// creates new collection with only string keys found in $collection
$filtered = $collection->filter('is_string', Collection::FILTER_KEY);

// Same as above, but reject all string keys
$filtered = $collection->reject('is_string', Collection::FILTER_KEY);

```

### Mutable Interface

[](#mutable-interface)

Various operations that change the collection state

$collection = new MutableCollection;

```
// set / unset key
$collection->set('key', 'value');
$collection->delete('key');

// Push element
$collection->add('value');

// remove all elements 'value'
$collection->remove('value');

// replace every occurrences of the element by a new one
$collection->replace('element', 'new one');

// Clear all collection elements
$collection->clear();

```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

10

Last Release

3983d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd14d27d458178e9515cf9a58b14bbe0b78f7c2113806aa97b3e16c94fe0a2e4?d=identicon)[ronan-gloo](/maintainers/ronan-gloo)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rubicon-collection/health.svg)

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

###  Alternatives

[hananils/kirby-colors

A color field for Kirby 3

5523.4k2](/packages/hananils-kirby-colors)

PHPackages © 2026

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