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

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

linkorb/collection
==================

Super powered collections

v1.0.0(8y ago)06444MITPHP

Since Aug 5Pushed 8y ago3 watchersCompare

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

READMEChangelog (1)DependenciesVersions (2)Used By (4)

Collection
==========

[](#collection)

This library implements a few helpful collection classes and interfaces.

TypedArray
----------

[](#typedarray)

This class behaves exactly like an array, but only allows items of a specified type:

```
$monkeys = new \Collection\TypedArray(Monkey::class);

$monkeys->add(new Monkey('Bubbles')); // OK
$monkeys[] = new Monkey('King Kong'); // OK
$monkeys->add(new Snake('Kaa')); // throws CollectionException

// You can iterate over the collection
foreach ($monkeys as $monkey) {
    echo $monkey->getName();
}
```

Adding items to a collection
----------------------------

[](#adding-items-to-a-collection)

You can add items in the regular array way:

```
$monkeys[] = new Monkey('King Kong');
```

Or use the `add()` method

```
$monkeys->add(new Monkey('King Kong'));
```

Identifiable interface
----------------------

[](#identifiable-interface)

The `Identifiable` class forces a class to implement the `identifier()` method. This method should return a key that makes this instance of a class unique. Maybe it's an ID, a key, a name, or an email address, as long as it uniquely identifies the item.

```
class Monkey implements \Collection\Identifiable
{
    protected $name;
    public function __construct($name)
    {
        $this->name = $name;
    }

    public function identifier()
    {
        return $this->name;
    }
}
```

When adding instances of this class to a collection, the identifier will automatically be used as the key:

```
$monkeys = new \Collection\TypedArray(Monkey::class);

$m1 = new Monkey('George');
$m2 = new Monkey('Koko');

$monkeys[] = $m1; // array contains 1 item
$monkeys[] = $m2; // array contains 2 item
$monkeys[] = $m2; // array still contains 2 items!
$monkeys->add($m2); // array still contains 2 items!

$monkeys->hasKey('George')); // returns true
$monkeys->hasKey('King Kong')); // returns false
isset($monkeys['George']); // returns true
```

Using collections in classes
----------------------------

[](#using-collections-in-classes)

```
class Zoo
{
    protected $monkeys;

    public function __construct()
    {
        $this->monkeys = new Collection\TypedArray(Monkey::class);
    }

    public function getMonkeys()
    {
        return $this->monkeys;
    }
}

$zoo = new Zoo();
$zoo->getMonkeys()->add(new Monkey('Koko');

foreach ($zoo->getMonkeys() as $monkey() {
}
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

Unknown

Total

1

Last Release

3206d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1db66b320db18b8036ea68211b7d8a39e7c6da97e6fd29f59a50380ebb69d0bb?d=identicon)[joostfaassen](/maintainers/joostfaassen)

---

Top Contributors

[![joostfaassen](https://avatars.githubusercontent.com/u/411113?v=4)](https://github.com/joostfaassen "joostfaassen (2 commits)")

---

Tags

arraycollectionlinkorbdata structurephp-ds

### Embed Badge

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

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

###  Alternatives

[aimeos/map

Easy and elegant handling of PHP arrays as array-like collection objects similar to jQuery and Laravel Collections

4.2k412.9k11](/packages/aimeos-map)[athari/yalinqo

YaLinqo, a LINQ-to-objects library for PHP

4561.2M5](/packages/athari-yalinqo)[yansongda/supports

common components

211.4M31](/packages/yansongda-supports)[armincms/json

A Laravel Nova field.

25149.4k3](/packages/armincms-json)[graze/sort

A collection of array sorting transforms and functions

12289.6k2](/packages/graze-sort)[graze/data-structure

Data collections and containers

12287.4k8](/packages/graze-data-structure)

PHPackages © 2026

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