PHPackages                             assegaiphp/collections - 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. assegaiphp/collections

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

assegaiphp/collections
======================

The assegaiphp/collections package is a powerful tool for creating and managing groups of related objects in your AssegaiPHP projects. With this library, you can easily organize and manipulate data in a variety of ways, such as arrays, lists, sets, and maps. The package offers a wide range of methods for adding, removing, and manipulating items, as well as sorting, searching, and filtering your collections. It is fully compatible with PHP 7.x and above and is designed to be lightweight and easy to use. Whether you're building a web application, a CLI tool, or a standalone script, assegaiphp/collections is the perfect choice for working with data. With its simple and intuitive interface, you can easily start working with collections in your project right away.

0.3.5(1mo ago)0342↓58.3%4MITPHPPHP &gt;=8.3

Since May 8Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/assegaiphp/collections)[ Packagist](https://packagist.org/packages/assegaiphp/collections)[ RSS](/packages/assegaiphp-collections/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (8)Used By (4)

 [![Assegai Logo](https://camo.githubusercontent.com/d7dab2658d76e460e31be249de2fe5d420f7a7237eb9f2a315f83123632a3b6c/68747470733a2f2f617373656761697068702e636f6d2f696d616765732f6c6f676f732f6c6f676f2d63726f707065642e706e67)](https://assegaiphp.com/)

A progressive [PHP](https://php.net) framework for building effecient and scalable server-side applications.

AssegaiPHP Collections
======================

[](#assegaiphp-collections)

A powerful and easy-to-use library for creating and managing collections of related objects in AssegaiPHP. This library provides a simple and intuitive interface for working with arrays of objects, making it easy to perform common operations such as filtering, mapping, and reducing.

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

[](#installation)

You can install the library using composer by running the following command:

```
composer require assegaiphp/collections
```

Usage
-----

[](#usage)

To create a new collection, you can use the `Assegai\Collections\Collection` class. This class provides a simple and intuitive interface for working with arrays of objects, making it easy to perform common operations such as filtering, mapping, and reducing.

Here's an example of how to create a new collection and add some items to it:

```
use Assegai\Collections\Collection;

$collection = new Collection();
$collection->add(1);
$collection->add(2);
$collection->add(3);
```

Collections are traversable, so you can iterate over them directly with `foreach`:

```
use Assegai\Collections\ItemList;

$list = new ItemList('string', ['foo', 'bar', 'baz']);

foreach ($list as $index => $item) {
    echo "{$index}: {$item}\n";
}
```

`ItemList` also supports array-style access for indexed reads and writes:

```
$list = new ItemList('string', ['foo', 'bar']);

echo $list[0]; // foo

$list[1] = 'baz';
$list[] = 'tail';

unset($list[0]);
```

Once you have a collection, you can use the various methods provided by the class to manipulate the items in the collection. For example, you can use the `filter` method to filter the items in the collection based on a certain condition:

```
$filteredCollection = $collection->filter(function($item) {
    return $item > 1;
});
```

The `map` method can be used to transform the items in the collection:

```
$mappedCollection = $collection->map(function($item) {
    return $item * 2;
});
```

You can also use the `reduce` method to reduce the collection to a single value:

```
$sum = $collection->reduce(function($carry, $item) {
    return $carry + $item;
}, 0);
```

API
---

[](#api)

The API of the `Assegai\Collections\Collection` class is designed to be simple and intuitive. It provides the following methods:

- `add(mixed $item)`: Add an item to the collection
- `remove(mixed $item)`: Remove an item from the collection
- `filter(callable $callback)`: Filter the items in collection based on a callback function.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance89

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.4% 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 ~208 days

Recently: every ~259 days

Total

6

Last Release

56d ago

PHP version history (2 changes)0.3.0PHP &gt;=8.2

0.3.4PHP &gt;=8.3

### Community

Maintainers

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

---

Top Contributors

[![amasiye](https://avatars.githubusercontent.com/u/5607605?v=4)](https://github.com/amasiye "amasiye (41 commits)")[![amasiyelr](https://avatars.githubusercontent.com/u/141437318?v=4)](https://github.com/amasiyelr "amasiyelr (7 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/assegaiphp-collections/health.svg)

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

###  Alternatives

[ideea/language-detector

Detect languages by text

334.4k](/packages/ideea-language-detector)

PHPackages © 2026

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