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(3mo ago)0156MITPHPPHP ^8.1

Since Feb 1Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Amo/Collection)[ Packagist](https://packagist.org/packages/amo/collection)[ RSS](/packages/amo-collection/feed)WikiDiscussions master Synced 1w 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

48

—

FairBetter than 95% of packages

Maintenance82

Actively maintained with recent releases

Popularity11

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

93d 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

[simshaun/recurr

PHP library for working with recurrence rules

1.6k15.7M40](/packages/simshaun-recurr)[alchemy/zippy

Zippy, the archive manager companion

47522.6M51](/packages/alchemy-zippy)[commerceguys/tax

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

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

Symfony cron

1901.5M2](/packages/cron-cron-bundle)[sonata-project/classification-bundle

Symfony SonataClassificationBundle

913.2M20](/packages/sonata-project-classification-bundle)[sylius/promotion

Flexible promotion management for PHP applications.

28477.8k9](/packages/sylius-promotion)

PHPackages © 2026

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