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

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

eslam-dev/collection
====================

Collection library

2.0.1(1y ago)029MITPHPPHP &gt;=5.6.0

Since Mar 25Pushed 1y ago1 watchersCompare

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

READMEChangelog (7)DependenciesVersions (9)Used By (0)

eslam-dev/collection
====================

[](#eslam-devcollection)

 **A PHP library for representing and manipulating collections.**

About
-----

[](#about)

`eslam-dev/collection` is a powerful PHP library for managing and manipulating collections. It provides an elegant API for working with arrays and objects, featuring advanced filtering, mapping, grouping, and transformation methods.

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

[](#installation)

---

Install the package using [Composer](https://getcomposer.org):

```
composer require eslam-dev/collection

```

Usage
-----

[](#usage)

---

### Generic Collection

[](#generic-collection)

The `collect` helper creates a new instance of the `EslamDev\Collection` class for the given array:

```
$collect = collect([
    ['id' => 1, 'name' => 'admin', 'type' => 'admin'],
    ['id' => 2, 'name' => 'admin 2', 'type' => 'admin'],
    ['id' => 3, 'name' => 'admin 3', 'type' => 'admin'],
    ['id' => 4, 'name' => 'admin 4', 'type' => 'admin'],
    ['id' => 5, 'name' => 'user 1', 'type' => 'user'],
]);
```

Methods and Examples
--------------------

[](#methods-and-examples)

### Methods

[](#methods)

#### \#merge

[](#merge)

Merge additional items into the collection:

```
$collect->merge([
    ['id' => 8, 'name' => 'user 4', 'type' => 'user'],
    ['id' => 9, 'name' => 'user 5', 'type' => 'user'],
]);
```

### \#add

[](#add)

Add a single item to the collection:

```
$collect->add(['id' => 10, 'name' => 'user 6', 'type' => 'user']);
```

### \#count

[](#count)

Count the total number of items in the collection:

```
$collect->count();
```

### \#where

[](#where)

Filter the collection by a specific key-value pair:

```
$collect->where('type', 'user');
```

### \#like

[](#like)

Filter items using a pattern. You can use `%` as a wildcard:

```
$collect->like('type', 'user');
// Supports array patterns
$collect->like('type', ['user', 'admin']);
```

### \#whereIn

[](#wherein)

Filter items where the key matches any value in an array:

```
$collect->whereIn('id', [1, 2, 3, 4]);
```

### \#whereNotIn

[](#wherenotin)

Filter items where the key does not match any value in an array:

```
$collect->whereNotIn('id', [5, 3, 7]);
```

### \#orderBy

[](#orderby)

Sort the collection by a specific key and direction:

```
$collect->orderBy('id', 'desc');
```

### \#first

[](#first)

Get the first item in the collection:

```
$collect->first();
```

### \#toArray

[](#toarray)

Convert the collection into an array:

```
$collect->toArray();
```

### \#toObject

[](#toobject)

Convert the collection into an object:

```
$collect->toObject();
```

License
-------

[](#license)

The `eslam-dev/collection` library is licensed under the MIT License. See the `LICENSE` file for details.

Author
------

[](#author)

This library is developed and maintained by [Eslam El Sherif](https://eslamelsherif.com).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance42

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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

Recently: every ~128 days

Total

8

Last Release

486d ago

Major Versions

1.2.3 → 2.0.02025-01-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/33e09cf047a9315be951b4592cb6be3b16fd6d160e744c8f02db07fa9e29c1bd?d=identicon)[eslam-dev](/maintainers/eslam-dev)

---

Top Contributors

[![eslam-dev](https://avatars.githubusercontent.com/u/21009117?v=4)](https://github.com/eslam-dev "eslam-dev (11 commits)")

### Embed Badge

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

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

###  Alternatives

[asantibanez/livewire-calendar

Laravel Livewire calendar component

96883.3k1](/packages/asantibanez-livewire-calendar)[akeneo/php-coupling-detector

Detect all the coupling issues of your project with respect to the coupling rules you have defined.

431.1M2](/packages/akeneo-php-coupling-detector)[runtime/swoole

Swoole runtime

56179.7k2](/packages/runtime-swoole)[helhum/typo3-config-handling

Simple but powerful configuration handling for TYPO3 CMS

37307.8k4](/packages/helhum-typo3-config-handling)[nickurt/laravel-stopforumspam

StopForumSpam for Laravel 11.x/12.x/13.x

6953.9k](/packages/nickurt-laravel-stopforumspam)[ralphschindler/basic-query-filter

Basic Query Filter

145.8k2](/packages/ralphschindler-basic-query-filter)

PHPackages © 2026

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