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

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

compolomus/collection
=====================

Collection

00PHP

Since Oct 5Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Compolomus/Collection)[ Packagist](https://packagist.org/packages/compolomus/collection)[ RSS](/packages/compolomus-collection/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Compolomus Collection
=====================

[](#compolomus-collection)

[![License](https://camo.githubusercontent.com/925145cd3487cf6c92581da35258cd38879542c29f5c8aea2874f2d78652ada0/68747470733a2f2f706f7365722e707567782e6f72672f636f6d706f6c6f6d75732f436f6c6c656374696f6e2f6c6963656e7365)](https://packagist.org/packages/compolomus/Collection)

[![Build Status](https://camo.githubusercontent.com/559655081292fbac4e4f00ee2acf7084eea6cdf2ca7e222c9e63b1b3c59568c5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f436f6d706f6c6f6d75732f436f6c6c656374696f6e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Compolomus/Collection/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/55004047b2389fde465a52adade984f00496ef1821368bb991c3c934c0322252/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f436f6d706f6c6f6d75732f436f6c6c656374696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Compolomus/Collection/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/9e98ec106c9b1caadf75bd247ea4ab6a5d62323f0e0acbd1497396210e6aec84/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f436f6d706f6c6f6d75732f436f6c6c656374696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Compolomus/Collection/?branch=master)[![Code Climate](https://camo.githubusercontent.com/73f33791ab0ee5acb5192f38b115ee762bb94ba71e622cc3040d09db5266ef37/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f436f6d706f6c6f6d75732f436f6c6c656374696f6e2f6261646765732f6770612e737667)](https://codeclimate.com/github/Compolomus/Collection)[![Downloads](https://camo.githubusercontent.com/6c54715afff98cc77af2188cd7ee94aadf2503d09bb0d5714c6c13c15ab8ebdc/68747470733a2f2f706f7365722e707567782e6f72672f636f6d706f6c6f6d75732f436f6c6c656374696f6e2f646f776e6c6f616473)](https://packagist.org/packages/compolomus/Collection)

Install:
========

[](#install)

composer require compolomus/Collection

Usage:
======

[](#usage)

```
use Compolomus\Collection\Collection;

require __DIR__ . '/vendor/autoload.php';
```

New collection
--------------

[](#new-collection)

### Single add

[](#single-add)

```
$collection = new Collection('stdClass');

for ($i = 0; $i test = $i;
    $collection->addOne($add);
}
```

### Batch add

[](#batch-add)

```
$array = [];
for ($i = 0; $i test = $i;
    $array[] = $add;
}
$collection->addAll($array);
```

Limit
-----

[](#limit)

### Count limit

[](#count-limit)

```
$limit1 = $collection->immutable()->limit(5);

echo '' . print_r($limit1->get(), true) . '';
/*
Array
(
    [0] => stdClass Object
        (
            [test] => 0
        )

    [1] => stdClass Object
        (
            [test] => 1
        )

    [2] => stdClass Object
        (
            [test] => 2
        )

    [3] => stdClass Object
        (
            [test] => 3
        )

    [4] => stdClass Object
        (
            [test] => 4
        )
)
 */

```

### Limit with offset

[](#limit-with-offset)

```
$limit2 = $collection->immutable()->limit(3, 3);

echo '' . print_r($limit2->get(), true) . '';
/*
Array
(
    [0] => stdClass Object
        (
            [test] => 3
        )

    [1] => stdClass Object
        (
            [test] => 4
        )

    [2] => stdClass Object
        (
            [test] => 5
        )
)
 */
```

Count
-----

[](#count)

```
echo $collection->count(); //43
echo $limit1->count(); // 5
echo $limit2->count(); // 3
```

Sort
----

[](#sort)

```
$sort = $limit2->immutable()->sort('test', Collection::DESC);

echo '' . print_r($sort->get(), true) . '';
/*
Array
(
    [2] => stdClass Object
        (
            [test] => 5
        )

    [1] => stdClass Object
        (
            [test] => 4
        )

    [0] => stdClass Object
        (
            [test] => 3
        )
)
 */
```

LINQ
----

[](#linq)

```
$linq = $collection->where('test > 33');

echo '' . print_r($linq->get(), true) . '';
/*
Array
(
    [0] => stdClass Object
        (
            [test] => 34
        )

    [1] => stdClass Object
        (
            [test] => 35
        )

    [2] => stdClass Object
        (
            [test] => 36
        )

    [3] => stdClass Object
        (
            [test] => 37
        )

    [4] => stdClass Object
        (
            [test] => 38
        )

    [5] => stdClass Object
        (
            [test] => 39
        )

    [6] => stdClass Object
        (
            [test] => 40
        )

    [7] => stdClass Object
        (
            [test] => 41
        )

    [8] => stdClass Object
        (
            [test] => 42
        )
)
 */
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![Compolomus](https://avatars.githubusercontent.com/u/10777258?v=4)](https://github.com/Compolomus "Compolomus (7 commits)")

### Embed Badge

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

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

###  Alternatives

[monsieurbiz/sylius-no-commerce-plugin

Disable the e-commerce on your Sylius.

1420.8k](/packages/monsieurbiz-sylius-no-commerce-plugin)

PHPackages © 2026

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