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

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

phf/collection
==============

Collections utility class

v1.0.0(5y ago)0150MITPHPPHP &gt;=7

Since May 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ph-fritsche/php-collection)[ Packagist](https://packagist.org/packages/phf/collection)[ RSS](/packages/phf-collection/feed)WikiDiscussions master Synced 1w ago

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

Collection
==========

[](#collection)

DRY helper for collections of validated elements.

With type hinted properties they can ensure type safety on collections without setters.

```
class Foo
{
    public StringCollection $bar;

    public function __construct()
    {
        $this->bar = new StringCollection();
    }
}

$foo = new Foo();
$foo->bar[] = 123; // throws InvalidArgumentException
```

Extend for own entities:

```
class BarEntity
{
    public string $baz;
}

class BarCollection extends \PhF\Collection\Collection
{
    protected static $invalidElementMessageAllowed = BarEntity::class;

    public function validate(
        $value
    ): bool {
        return $value instanceof BarEntity;
    }
}

class Foo
{
    public BarCollection $bar;

    public function __construct()
    {
        $this->bar = new BarCollection();
    }
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Unknown

Total

1

Last Release

1839d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/14faf0e942f2e3361ad07e017bf356d02bb7b76ab47d66a0d52faf4c03e6faec?d=identicon)[ph.fritsche](/maintainers/ph.fritsche)

---

Top Contributors

[![ph-fritsche](https://avatars.githubusercontent.com/u/39068198?v=4)](https://github.com/ph-fritsche "ph-fritsche (3 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[botman/tinker

BotMan tinker command for your Laravel BotMan project

102201.2k4](/packages/botman-tinker)[msa/laravel-grapes

laravel grapes is a cms drag and drop page builder

1853.1k](/packages/msa-laravel-grapes)[tizis/lara-comments

Comments system for your Laravel application. Features: can be used to comment on any model, HTML filter customization (HTMLPurifier), API, comment rating, replies, events, auth rules ...

1194.7k](/packages/tizis-lara-comments)[bircher/php-merge

A PHP merge utility using the Diff php library or the command line git.

3729.2k](/packages/bircher-php-merge)[degordian/yii2-webhooks

Yii2 extension for webhooks

117.1k](/packages/degordian-yii2-webhooks)

PHPackages © 2026

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