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

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

zalas/collections
=================

A tiny collection library

v1.1.0(6y ago)83MITPHPPHP ^7.3

Since Oct 1Pushed 6y ago1 watchersCompare

[ Source](https://github.com/jakzal/collections)[ Packagist](https://packagist.org/packages/zalas/collections)[ RSS](/packages/zalas-collections/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

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

[](#collections)

[![Build Status](https://camo.githubusercontent.com/a404522fedcdb69e98eab0c8bc3df6cdd78bfb0ce840d9544ac7ba497da14b49/68747470733a2f2f7472617669732d63692e636f6d2f6a616b7a616c2f636f6c6c656374696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/jakzal/collections)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/555f139de829a5f0d2a4353b45c03bc9ec3f14ab6fdbf128525f92a4affdb4d4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a616b7a616c2f636f6c6c656374696f6e732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jakzal/collections/?branch=master)

A tiny collection library enabling `array_*` like operations on generators and other traversables.

Collection interface
--------------------

[](#collection-interface)

```
interface Collection extends IteratorAggregate
{
    public function merge(Collection $other): Collection;

    public function filter(callable $f): Collection;

    public function map(callable $f): Collection;

    /**
     * @param mixed $initial
     * @param callable $f
     *
     * @return mixed
     */
    public function reduce($initial, callable $f);
}
```

Collection implementations
--------------------------

[](#collection-implementations)

### LazyCollection

[](#lazycollection)

The lazy collection implementation postpones evaluation of elements until it's necessary.

```
use Zalas\Collection\LazyCollection;

$c = (new LazyCollection(new \ArrayIterator([1, 2, 3, 4])))
    ->filter(fn (int $e) => 0 === $e % 2)
    ->map(fn (int $e) => $e * 2)
;
```

In legacy PHP versions:

```
use Zalas\Collection\LazyCollection;

$c = (new LazyCollection(new \ArrayIterator([1, 2, 3, 4)))
    ->filter(function (int $e) {
        return 0 === $e % 2;
    })
    ->map(function (int $e) {
        return $e * 2;
    })
;
```

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

[](#installation)

```
composer require zalas/collections

```

Contributing
------------

[](#contributing)

Please read the [Contributing guide](CONTRIBUTING.md) to learn about contributing to this project. Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Total

3

Last Release

2229d ago

PHP version history (2 changes)v1.0.0PHP ^7.2

v1.1.0PHP ^7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/012270929478a287f88353135a39d275db09c1856d344d0245e04df709879262?d=identicon)[jakzal](/maintainers/jakzal)

---

Top Contributors

[![jakzal](https://avatars.githubusercontent.com/u/190447?v=4)](https://github.com/jakzal "jakzal (23 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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