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

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

camelot/collection
==================

Object Orientated implementations of various collections

v1.1.1(4y ago)099MITPHPPHP ^7.1.3 || ^8.0

Since Sep 1Pushed 4y ago1 watchersCompare

[ Source](https://github.com/CamelotProject/collection)[ Packagist](https://packagist.org/packages/camelot/collection)[ RSS](/packages/camelot-collection/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (8)Versions (6)Used By (0)

Camelot Collection
==================

[](#camelot-collection)

This library provides objects and functionality to help with groups of items and data sets.

Check out the \[API documentation\]\[api-docs\].

`Bag` and `MutableBag`
----------------------

[](#bag-and-mutablebag)

These are object-oriented implementations of arrays.

The goal of these classes:

- Provide functionality on par with built-in array methods
- Provide useful functionality lacking from built-in array methods
- Provide a fluent-like experience
- Make implementing code more readable

### Examples

[](#examples)

```
$arr = [
    'debug' => true,
    'color' => 'blue',
    'db' => [
        'driver' => 'sqlite',
    ],
];

$bag = Bag::from($arr)
    ->defaults([
        'debug' => false,
        'color' => 'green',
    ])
    ->replace([
        'color' => 'red',
    ])
;
$bag->get('debug'); // true
$bag->getPath('db/driver'); // "sqlite"
$bag->keys()->join(', '); // "debug, color, db"
$bag->isAssociative(); // true
```

```
$colors = MutableBag::of('red', 'blue', 'yellow')
    ->merge(['green', 'orange'])
;
$colors->isIndexed(); // true
$colors->indexOf('yellow'); // 2
$colors[2]; // "yellow"

$colors->prepend('purple');
$colors[] = 'pink';

$colors->first(); // "purple"
$colors->last(); // "pink"

$colors->shuffle()->first(); // one of the colors

$colors->chunk(2); // Bags represented as arrays:
// [ ['purple', 'red'], ['blue', 'yellow'], ['green, 'orange'], ['pink'] ]

$colors->removeFirst(); // "purple"
$colors->removeFirst(); // "red"
```

All methods accepting a collection will accept other `Bags`, `arrays`, `stdClass`, and `Traversable` objects. This makes it very easy work with any collection-like object.

### Hasn't this been done already?

[](#hasnt-this-been-done-already)

Obviously others think PHP arrays suck as well and have attempted to resolve this.

Symfony's `ParameterBag` is a good basic *map* (associative arrays) container but is lacking when it comes to mutating the items around and working with lists.

Doctrine's `ArrayCollection` is also another, more robust, option. It works well for maps and lists, but still has limited functionality due to needing to interface with a database collection. It also has some annoyances, like `getKeys()` returns an `array` instead of another `ArrayCollection` instance.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 58.7% 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 ~387 days

Total

4

Last Release

1649d ago

PHP version history (2 changes)v1.0.0-beta1PHP ^7.1.3

v1.1.0PHP ^7.1.3 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22109404?v=4)[gwendolen](/maintainers/gwendolen)[@gwendolen](https://github.com/gwendolen)

---

Top Contributors

[![CarsonF](https://avatars.githubusercontent.com/u/932566?v=4)](https://github.com/CarsonF "CarsonF (71 commits)")[![GwendolenLynch](https://avatars.githubusercontent.com/u/1427081?v=4)](https://github.com/GwendolenLynch "GwendolenLynch (50 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[phpdocumentor/reflection-docblock

With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.

9.4k722.2M1.2k](/packages/phpdocumentor-reflection-docblock)[icanhazstring/composer-unused

Show unused packages by scanning your code

1.7k7.0M188](/packages/icanhazstring-composer-unused)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[phpdocumentor/reflection

Reflection library to do Static Analysis for PHP Projects

12521.4M109](/packages/phpdocumentor-reflection)[sylius/promotion

Flexible promotion management for PHP applications.

28477.8k9](/packages/sylius-promotion)[sylius/taxonomy

Taxonomies - categorization of domain models in PHP projects.

14435.6k10](/packages/sylius-taxonomy)

PHPackages © 2026

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