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

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

amo/collection
==============

Collection Abstraction library extended

v1.0.0(4mo ago)0156MITPHPPHP ^8.1

Since Feb 1Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/Amo/Collection)[ Packagist](https://packagist.org/packages/amo/collection)[ RSS](/packages/amo-collection/feed)WikiDiscussions master Synced 3w ago

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

Collection
==========

[](#collection)

Collection management, heavily inspired by Doctrine ArrayCollection

Install
=======

[](#install)

```
composer require amo/collection

```

Docker (latest PHP)
===================

[](#docker-latest-php)

```
docker compose build
docker compose run --rm php composer install
docker compose run --rm php vendor/bin/phpunit -c phpunit.xml

```

Methods: Usage + Outcome
========================

[](#methods-usage--outcome)

```
use Amo\Collection\Collection;
```

`make` / `create`

- `Collection::make([1, 2, 3])` -&gt; collection with values `[1, 2, 3]`
- `Collection::create(['a' => 10])` -&gt; collection with key/value `['a' => 10]`

`each` (return value ignored, iterates all)

- `Collection::make([1, 2, 3])->each(fn(int $v) => print($v));` -&gt; prints `123`

`map`

- `Collection::make([1, 2])->map(fn(int $v) => $v * 10)->getValues()` -&gt; `[10, 20]`

`flatMap`

- `Collection::make([[1, 2], [3]])->flatMap(fn(array $x) => $x)->getValues()` -&gt; `[1, 2, 3]`

`find`

- `Collection::make([1, 3, 5])->find(fn(int $v) => $v > 2)` -&gt; `3`
- `Collection::make([1, 3, 5])->find(fn(int $v) => $v > 9)` -&gt; `null`

`groupBy`

- `Collection::make([['n' => 'a', 't' => 'x'], ['n' => 'b', 't' => 'x'], ['n' => 'c', 't' => 'y']])->groupBy(fn(array $i) => $i['t'])`
- Outcome: keys `x`, `y`, each value is a `Collection` of matching rows

`keyBy`

- `Collection::make([['id' => 10], ['id' => 20]])->keyBy(fn(array $i) => $i['id'])->getKeys()` -&gt; `[10, 20]`

`take` / `drop`

- `Collection::make([1, 2, 3, 4])->take(2)->getValues()` -&gt; `[1, 2]`
- `Collection::make([1, 2, 3, 4])->drop(2)->getValues()` -&gt; `[3, 4]`

`merge`

- `Collection::make([3, 4])->merge(Collection::make([1, 2]))->getValues()` -&gt; `[1, 2, 3, 4]`

`append` (mutates current collection)

- `$c = Collection::make([1]); $c->append(Collection::make([2, 3])); $c->getValues()` -&gt; `[1, 2, 3]`

`copy`

- `$a = Collection::make([1]); $b = $a->copy();` -&gt; same values, different instance

`usort` / `sort`

- `Collection::make([2, 1, 3])->sort(fn(int $a, int $b) => $a  $b)->getValues()` -&gt; `[1, 2, 3]`

`flatten`

- `Collection::make([[1, 2], 3, [4]])->flatten()->getValues()` -&gt; `[1, 2, 3, 4]`

`flip`

- `Collection::make(['a' => 'x', 'b' => 'y'])->flip()->toArray()` -&gt; `['x' => 'a', 'y' => 'b']`

`unique`

- `Collection::make([1, 1, 2, 2])->unique()->getValues()` -&gt; `[1, 2]`

`intersect`

- `Collection::make([1, 2, 3])->intersect(Collection::make([2, 4, 3]))->getValues()` -&gt; `[2, 3]`

`diff`

- `Collection::make([1, 2, 3])->diff(Collection::make([2, 4]))->getValues()` -&gt; `[1, 3]`

`reduce`

- `Collection::make([1, 2, 3])->reduce(fn(array $acc, int $v) => [...$acc, $v * 2], [])->getValues()` -&gt; `[2, 4, 6]`

`sum`

- `Collection::make([['amount' => 1.5], ['amount' => 2.5]])->sum(fn(array $i) => $i['amount'], 1)` -&gt; `5.0`

`slice`

- `Collection::make([1, 2, 3, 4])->slice(1, 2)->getValues()` -&gt; `[2, 3]`

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance74

Regular maintenance activity

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity76

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

Total

5

Last Release

140d ago

Major Versions

v0.0.4 → v1.0.02026-02-14

PHP version history (4 changes)v0.0.1PHP ^7.1

v0.0.3PHP &gt;=7.1

v0.0.4PHP ^7.1 || ^8.0

v1.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/36977?v=4)[Amaury Leroux de Lens](/maintainers/amo)[@Amo](https://github.com/Amo)

---

Top Contributors

[![Amo](https://avatars.githubusercontent.com/u/36977?v=4)](https://github.com/Amo "Amo (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[oat-sa/tao-core

TAO core extension

66143.7k124](/packages/oat-sa-tao-core)[akeneo/pim-community-dev

Akeneo PIM, the future of catalog management is open!

1.0k624.1k85](/packages/akeneo-pim-community-dev)[commerceguys/tax

Tax library with a flexible data model, predefined tax rates, powerful resolving logic.

285781.2k](/packages/commerceguys-tax)[cron/cron-bundle

Symfony cron

1921.5M2](/packages/cron-cron-bundle)[prestashop/ps_facetedsearch

PrestaShop module ps\_facetedsearch

618.3M4](/packages/prestashop-ps-facetedsearch)[api-platform/doctrine-common

Common files used by api-platform/doctrine-orm and api-platform/doctrine-odm

274.4M48](/packages/api-platform-doctrine-common)

PHPackages © 2026

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