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

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

jjgrainger/collection
=====================

Simple collections in PHP

1.1(6y ago)12162MITPHPPHP &gt;=7.2CI failing

Since Mar 12Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/jjgrainger/Collection)[ Packagist](https://packagist.org/packages/jjgrainger/collection)[ Docs](https://github.com/jjgrainger/collection)[ RSS](/packages/jjgrainger-collection/feed)WikiDiscussions main Synced yesterday

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

Collection v1.1
===============

[](#collection-v11)

> A collection class for working with arrays

[![tests](https://github.com/jjgrainger/Collection/actions/workflows/tests.yml/badge.svg)](https://github.com/jjgrainger/Collection/actions/workflows/tests.yml) [![codecov](https://camo.githubusercontent.com/2fcd3fc19230637f45a6b2c83dfa8de62884887b9f44a0fb529e20e7235dfe64/68747470733a2f2f636f6465636f762e696f2f67682f6a6a677261696e6765722f436f6c6c656374696f6e2f67726170682f62616467652e7376673f746f6b656e3d584d4c7a564f634c4842)](https://codecov.io/gh/jjgrainger/Collection) [![Latest Stable Version](https://camo.githubusercontent.com/47275a2a83743a496654d054f0fad43bfa554927a95d50ce4422d656b185cb64/68747470733a2f2f62616467656e2e6e65742f6769746875622f72656c656173652f6a6a677261696e6765722f436f6c6c656374696f6e2f737461626c65)](https://packagist.org/packages/jjgrainger/collection) [![Total Downloads](https://camo.githubusercontent.com/cdda6e35c4a585846deb2182116cf7bbd71fa1d0dd248e86a2e185b155437fdc/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f6a6a677261696e6765722f436f6c6c656374696f6e)](https://packagist.org/packages/jjgrainger/collection) [![License](https://camo.githubusercontent.com/1bb09fa86ca1eaa365713ea469a028c92fdf2819aa07a1bacf75197b81376e6c/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6963656e73652f6a6a677261696e6765722f436f6c6c656374696f6e)](https://packagist.org/packages/jjgrainger/collection)

Principles
----------

[](#principles)

- Immutable - Most methods return a new collection, leaving the previous untouched
- Chainable - Methods can be chained to create fluent mapping and reduce original collection

Requirements
------------

[](#requirements)

- PHP &gt;=7.2
- [Composer](https://getcomposer.org/)

Installation
------------

[](#installation)

```
$ composer require jjgrainger/collection

```

Usage
-----

[](#usage)

```
$collection = new Collection([1, 2, 3]);

$total = $collection->sum(); // 6
```

Notes
-----

[](#notes)

- This project was created to learn unit testing, not intended for production use.
- Inspired by [Laravel Collections](https://laravel.com/docs/5.8/collections)
- Licensed under the [MIT License](https://github.com/jjgrainger/wp-posttypes/blob/master/LICENSE)
- Maintained under the [Semantic Versioning Guide](https://semver.org)

Author
------

[](#author)

**Joe Grainger**

-
-

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance54

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.2% 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 ~657 days

Total

2

Last Release

2326d ago

PHP version history (2 changes)1.0PHP &gt;=5.3.0

1.1PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/e75df324c03b826071d520965956f3bbb8353970080cdfb1c93a742ea0a4ee44?d=identicon)[jjgrainger](/maintainers/jjgrainger)

---

Top Contributors

[![jjgrainger](https://avatars.githubusercontent.com/u/904708?v=4)](https://github.com/jjgrainger "jjgrainger (25 commits)")[![bramvanrijswijk](https://avatars.githubusercontent.com/u/26224522?v=4)](https://github.com/bramvanrijswijk "bramvanrijswijk (1 commits)")

---

Tags

collectionphp

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[upyun/sdk

UPYUN sdk for php

174100.6k22](/packages/upyun-sdk)[webdevstudios/cmb2-attached-posts

Custom field for CMB2 for creating post relationships.

13565.5k](/packages/webdevstudios-cmb2-attached-posts)[pharmaintelligence/hl7

HL7 PHP Library.

23200.4k](/packages/pharmaintelligence-hl7)[magepow/layerednav

Magento 2 Advanced Layered Navigation Ajax

1712.1k](/packages/magepow-layerednav)

PHPackages © 2026

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