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

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

novactive/collection
====================

++ Collection ++ Abstaction library for PHP.

v3.1.0(5y ago)1152.4k↓33.3%3[7 issues](https://github.com/Novactive/NovaCollection/issues)1MITPHPPHP ^7.4 || ^8.0CI failing

Since Feb 6Pushed 5y ago6 watchersCompare

[ Source](https://github.com/Novactive/NovaCollection)[ Packagist](https://packagist.org/packages/novactive/collection)[ Docs](https://github.com/Novactive/NovaCollection)[ RSS](/packages/novactive-collection/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (11)Used By (1)

BranchTravisSensio InsightScrutinizer QualityScrutinizer Coveragedevelop[![Build Status](https://camo.githubusercontent.com/bc0c12e25c0eb9d36564a1df840f138be4c71e2f727d669441c743c908fe69e6/68747470733a2f2f7472617669732d63692e6f72672f4e6f766163746976652f4e6f7661436f6c6c656374696f6e2e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/Novactive/NovaCollection)[![SensioLabsInsight](https://camo.githubusercontent.com/c605f796bd3629c6d35b7c05fac2d468d6d331967e36d459a88425dbe0e4620b/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f30643533343835642d356662662d343661302d613163322d6335633837396137386231652f6d696e692e706e67)](https://insight.sensiolabs.com/projects/0d53485d-5fbf-46a0-a1c2-c5c879a78b1e)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/995909211d98dd568690d80e29a4a2774ece7f66917be3132e22321166492971/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4e6f766163746976652f4e6f7661436f6c6c656374696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/Novactive/NovaCollection/?branch=develop)[![Code Coverage](https://camo.githubusercontent.com/2afc839253d24a3db8633bc9fa569b6fd1b7addef2b91da6a6525a2c37fcf032/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4e6f766163746976652f4e6f7661436f6c6c656374696f6e2f6261646765732f636f7665726167652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/Novactive/NovaCollection/?branch=develop)master[![Build Status](https://camo.githubusercontent.com/b74196730716b1b081e374a70ce048820b3fb1952bd016aabb9162127ea13e35/68747470733a2f2f7472617669732d63692e6f72672f4e6f766163746976652f4e6f7661436f6c6c656374696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Novactive/NovaCollection)[![SensioLabsInsight](https://camo.githubusercontent.com/354e6b64d08ac8b29e843f3e5723d20dd44aaca36d98c42fa2bcbdd6f8262d61/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f38323736623238312d656138322d343233632d383732352d6236653931363332363064652f6d696e692e706e67)](https://insight.sensiolabs.com/projects/8276b281-ea82-423c-8725-b6e9163260de)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2b1a73a469df6d9e80a41b2d7867eb0e137d9b68c099da024645afddf06dd47b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4e6f766163746976652f4e6f7661436f6c6c656374696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Novactive/NovaCollection/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/01453cb26c0836cda7a51b2514fea7dc1acdab088c0efb81b6ca1702757b64b9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4e6f766163746976652f4e6f7661436f6c6c656374696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Novactive/NovaCollection/?branch=master)Nova Collection
===============

[](#nova-collection)

Because we did not find any *Collection* for PHP as simple as we wanted, we did ours.

Simpler, Better, Faster, Stronger
---------------------------------

[](#simpler-better-faster-stronger)

Using *array\_*\* functions against *foreach* is not an easy pick. As this library is made to manage low level actions. We wanted it to be fast, then we compared and we implemented the best choices. (have a look: [PHP7.2](https://i.imgur.com/JUUo6EE.png))

Fully unit tested it is reliable.

Methods
-------

[](#methods)

### Advanced Selection by range

[](#advanced-selection-by-range)

```
$collection = NovaCollection([0,1,2,3,4,5,6,7,8,9,10]);
$collection([2,4], 1, 2, '4-2', '3,2;5-2;10')->toArray();
```

> Result: \[2,3,4,1,2,4,3,2,3,4,5,4,3,2,10\]

### Standard Manipulation Methods

[](#standard-manipulation-methods)

MethodDescriptiontoArray()Get the raw Array.set($key, $value)Set the value to the key no matter what.get($key, $default)Get the value related to the key.atIndex(int $index)Get the item at the given index (numerically).keyOf($value)Get the key of a value if exists.indexOf($value)Get the index of a value if exists (numerically).containsKey($key)Test is the key exists.contains($value)Test if this values exists.add($item)Add a new value to the collection, next numeric index will be used. (in-place).append(iterable $values)Append the items at the end of the collection not regarding the keys. (in-place).clear()Clear the collection of all its items. (in-place).remove($key)Remove the $key/value in the collection. (in-place).pull($key)Remove the $key/value in the collection and return the removed value. (in-place).first(callable $callback)Get the first time and reset and rewind.shift()Shift an element off the beginning of the collection. (in-place).pop()Shift an element off the end of the collection. (in-place).last(callable $callback)Get the last item.map(callable $callback)Map and return a new Collection.mapKeys(callable $callback, callable $callbackValue)Map keys (and/or value) and return a new Collection.transform(callable $callback)Map. (in-place).filter(callable $callback)Filter and return a new Collection.prune(callable $callback)Filter. (in-place).combine(iterable $values, bool $inPlace)Combine and return a new Collection.replace(iterable $values)Combine. (in-place).combineKeys(iterable $keys)Opposite of Combine It keeps the values of the current Collection and assign new keys.reindex(iterable $keys)CombineKeys. (in-place).reduce(callable $callback, $initial)Reduce.each(callable $callback)Run the callback on each element. (passive).flip()Flip the keys and the values and return a new Collection.invert()Flip. (in-place).merge(iterable $items, bool $inPlace)Merge the items and the collections and return a new Collection.coalesce(iterable $items)Merge. (in-place).union(iterable $items, bool $inPlace)Union the collection with Items and return a new Collection.absorb(iterable $items)Union. (in-place).assert(callable $callback, bool $expected)Assert that the callback result is $expected for all.values()Return all the values.keys()Return all the keys.pipe(callable $callback)Pass the collection to the given callback and return the result.shuffle()Random. (in-place).random()Shuffle and return a new Collection.unique()Deduplicate the collection and return a new Collection.implode(string $separator)Join the items using the $separator.distinct()Unique. (in-place).zip(iterable $items)Merge the values items by items and return a new Collection.reverse()Reverse the collection and return a new Collection.inverse()Reverse. (in-place).isEmpty()Tells if the collection is empty.split(int $count)Split in the collection in $count parts and return a new Collection.chunk(int $size)Chunk of $size sub collection and return a new Collection.slice(int $offset, int $length)Get a slice of the collection and inject it in a new Collection.keep(int $offset, int $length)Keep a slice of the collection. (in-place).applyOn($key, callable $onKeyFound, callable $onKeyNotFound)Apply the callback $onKeyFound on the key/value if the key exists. (passive).cut(int $offset, int $length)Cut a slice of the collection. (in-place).diff(iterable $items)Compares the collection against $items and returns the values that are not present in the collection.diffKeys(iterable $items)Compares the collection against $items and returns the keys that are not present in the collection.intersect(iterable $items)Compares the collection against $items and returns the values that exist in the collection.intersectKeys(iterable $items)Compares the collection against $items and returns the keys that exist in the collection.exists(callable $callback)Return true if one item return true to the callback.Contributing
------------

[](#contributing)

In order to be accepted, your contribution needs to pass a few controls:

- PHP files should be valid
- PHP files should follow the [PSR-2](http://www.php-fig.org/psr/psr-2/) standard
- PHP files should be [phpmd](https://phpmd.org) and [phpcpd](https://github.com/sebastianbergmann/phpcpd) warning/error free

To ease the validation process, you can use these 2 scripts:

### Coding Standards and syntax

[](#coding-standards-and-syntax)

```
make codeclean
```

> will check and fix the Coding Standards

### Tests

[](#tests)

```
make tests
```

> will run the tests

Changelog
---------

[](#changelog)

[Changelog](doc/CHANGELOG.md)

LICENSE
-------

[](#license)

[License](LICENSE)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity74

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

Recently: every ~35 days

Total

8

Last Release

1897d ago

Major Versions

1.0.0 → 2.0.02018-12-08

2.0.1 → v3.0.02020-10-17

1.1.0 → v3.1.02021-03-08

PHP version history (6 changes)1.0.0PHP ^5.6 || ^7.0

2.0.0PHP ^7.2

v3.0.0PHP ^7.4

v3.1.0PHP ^7.4 || ^8.0

2.1.0PHP ^7.2 || 8.0

2.1.1PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/313532?v=4)[Sébastien Morel](/maintainers/Plopix)[@Plopix](https://github.com/Plopix)

---

Top Contributors

[![Plopix](https://avatars.githubusercontent.com/u/313532?v=4)](https://github.com/Plopix "Plopix (90 commits)")

---

Tags

arraycollectionfunctional-programmingphpphp7symfony

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[adhocore/underscore

PHP underscore inspired &amp;amp;/or cloned from \_.js

435.1k](/packages/adhocore-underscore)

PHPackages © 2026

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