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

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

malarzm/collections
===================

Various implementations of Doctrine's Collection interface

1.0.0(9y ago)2368.1k1[1 PRs](https://github.com/malarzm/collections/pulls)MITPHPPHP &gt;=5.4

Since Mar 4Pushed 8y ago2 watchersCompare

[ Source](https://github.com/malarzm/collections)[ Packagist](https://packagist.org/packages/malarzm/collections)[ Docs](http://www.doctrine-project.org)[ RSS](/packages/malarzm-collections/feed)WikiDiscussions master Synced 1mo ago

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

Collections
===========

[](#collections)

[![Build Status](https://camo.githubusercontent.com/940117646f8c4ad2176fc9b5878f2625bce9f16803d1f34fd6be8d0528b45cb6/68747470733a2f2f7472617669732d63692e6f72672f6d616c61727a6d2f636f6c6c656374696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/malarzm/collections)

Various implementations of Doctrine's Collection interface allowing you to kickstart development of own ones. Each time an interface or an abstract class requires you to implement `compare` method it needs a standard PHP comparison function that returns an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

This library sports:

SortedCollection
----------------

[](#sortedcollection)

Collection that ensures it is always sorted, uses `uasort` by default however this can be changed via constructor argument. Example usage:

```
class SortedCollection extends Malarzm\Collections\SortedCollection
{
    public function compare($a, $b)
    {
        // ...
    }
}

$coll = new SortedIntCollection([], 'usort');
```

ObjectSet
---------

[](#objectset)

Collection that ensures it contains only one instance of a given object at a time thus providing very efficient `contains` implementation. Add/set calls are NOP in case of object being already in the collection.

It's ready to use right away.

Set
---

[](#set)

More general version of `ObjectSet` that bases on custom comparison function instead of object hashes effectively allowing you to store any kind of values in it. Add/set calls are NOP in case of value being already in the collection.

```
class Set extends Malarzm\Collections\Set
{
    public function compare($a, $b)
    {
        // ...
    }
}
```

Diffable
--------

[](#diffable)

Collection that allows you to track changes done between snapshots (first one is taken just after constructing collection, next are taken at the discretion of developer by calling `->snapshot()`). Use `->getAddedElements()` and `->getRemovedElements()` to get new and no longer existing elements respectively.

```
class Diffable extends Malarzm\Collections\Diffable
{
    public function compare($a, $b)
    {
        // ...
    }
}
```

Library also ships `Malarzm\Collections\DiffableCollection` interface than can be backed up by `Malarzm\Collections\Mixin\Diffable` trait for your own use.

ListArray
---------

[](#listarray)

Collection that ensures held elements are always stored as a list (array indexed by consecutive numbers). An exception is thrown when trying to write to invalid index.

It's ready to use right away.

SortedList
----------

[](#sortedlist)

Extended implementation of `ListArray` that additionally keeps elements sorted thus providing more efficient `contains`, `indexOf` and `removeElement` implementations.

```
class SortedList extends Malarzm\Collections\SortedList
{
    public function compare($a, $b)
    {
        // ...
    }
}
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 96.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 ~281 days

Total

2

Last Release

3446d ago

Major Versions

0.1.0 → 1.0.02016-12-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/09395def7b7f6c5cfa2cd4b2a115036b9b0c007c16edc114071ddab8b2505f34?d=identicon)[malarzm](/maintainers/malarzm)

---

Top Contributors

[![malarzm](https://avatars.githubusercontent.com/u/4947711?v=4)](https://github.com/malarzm "malarzm (29 commits)")[![alcaeus](https://avatars.githubusercontent.com/u/383198?v=4)](https://github.com/alcaeus "alcaeus (1 commits)")

---

Tags

arrayiteratorcollections

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k411.1M1.2k](/packages/doctrine-collections)[athari/yalinqo

YaLinqo, a LINQ-to-objects library for PHP

4561.2M5](/packages/athari-yalinqo)[ginq/ginq

LINQ to Object inspired DSL for PHP

192257.5k3](/packages/ginq-ginq)[rotexsoft/versatile-collections

A collection package that can be extended to implement things such as a Dependency Injection Container, RecordSet objects for housing database records, a bag of http cookies, or technically any collection of items that can be looped over and whose items can each be accessed using array-access syntax or object property syntax.

186.0k1](/packages/rotexsoft-versatile-collections)[vistik/typed-collections

A simple way to create typed collections in PHP - build on Illuminate\\Support\\Collection

1128.2k5](/packages/vistik-typed-collections)[chdemko/bitarray

BitArray for PHP &gt;= 8.2

1116.2k](/packages/chdemko-bitarray)

PHPackages © 2026

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