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

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

andileong/collection
====================

A simple array collection component

v0.1.1(4y ago)031PHPPHP ^8.0

Since Oct 14Pushed 3y ago1 watchersCompare

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

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

A simple array collection
-------------------------

[](#a-simple-array-collection)

Has been use laravel collection for sometime I decided to make a simple collection wrapper for array function where you can chain array method call

It really feels like OOP, below are some methods (mostly steal the method name from laravel but I create my own implementation)

- map
- filter
- pluck
- unique
- only
- first
- last
- second
- sum
- average
- isEmpty
- has
- limit
- remove
- sortBy
- ...

Using multiple native php array function may not feel very oop , I think it's a good idea to wrap it, as a learning practice for me, mostly is inspired by Laravel framework

If you are looking for a robust implementation for collection please look for

Usage
-----

[](#usage)

let say we have list of users, we want to get all subscribed users order by latest date and give me the latest 3 records and capitalize the username

```
use Andileong\Collection\Collection;

$array = [
            [
                'id' => 1,
                'name' => 'andi fake',
                'is_subscribed' => true,
                'created_at' => '2021-05-07T09:51:51.000000Z',
            ],
            [
                'id' => 2,
                'name' => 'Betty Waters',
                'is_subscribed' => false,
                'created_at' => '2021-04-07T09:51:51.000000Z',
            ],
            [
                'id' => 3,
                'name' => 'Landen Spinka',
                'is_subscribed' => true,
                'created_at' => '2021-01-07T09:51:51.000000Z',
            ],
            [
                'id' => 4,
                'name' => 'Dell Stoltenberg',
                'is_subscribed' => false,
                'created_at' => '2021-09-07T09:51:51.000000Z',
            ],
            [
                'id' => 5,
                'name' => 'Guy Moen PhD',
                'is_subscribed' => true,
                'created_at' => '2021-07-07T09:51:51.000000Z',
            ],
            [
                'id' => 6,
                'name' => 'Ida Swaniawski',
                'is_subscribed' => false,
                'created_at' => '2021-05-07T09:51:51.000000Z',
            ],
            [
                'id' => 7,
                'name' => 'Norberto Baumbach',
                'is_subscribed' => false,
                'created_at' => '2021-06-07T09:51:51.000000Z',
            ],
            [
                'id' => 8,
                'name' => 'McDermott',
                'is_subscribed' => true,
                'created_at' => '2021-08-07T09:51:51.000000Z',
            ],
            [
                'id' => 9,
                'name' => 'Lavon Nitzsche DDS',
                'is_subscribed' => true,
                'created_at' => '2021-06-07T09:51:51.000000Z',
            ],
            [
                'id' => 10,
                'name' => 'Natalie Huel',
                'is_subscribed' => true,
                'created_at' => '2021-01-07T09:51:51.000000Z',
            ],
        ];

//we can do as below chaining call

$collection = Collection::make($array);
$collection = $collection
    ->filter( fn($user) => $user['is_subscribed'] )
    ->map( function ($user) {
        $user['name'] = strtoupper($user['name']);
        return $user;
    })
    ->sortBy('created_at', SORT_DESC)
    ->limit(3);
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Total

2

Last Release

1532d ago

### Community

Maintainers

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

---

Top Contributors

[![andiLeong](https://avatars.githubusercontent.com/u/68339288?v=4)](https://github.com/andiLeong "andiLeong (13 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[coenjacobs/mozart

Composes all dependencies as a package inside a WordPress plugin

4723.6M20](/packages/coenjacobs-mozart)[illuminate/session

The Illuminate Session package.

9937.4M753](/packages/illuminate-session)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)

PHPackages © 2026

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