PHPackages                             flying/handlers-list - 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. flying/handlers-list

ActiveLibrary

flying/handlers-list
====================

Implementation of generic list of arbitrary handlers

v3.0.0(5y ago)014MITPHPPHP ^7.4|^8.0

Since Jun 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/FlyingDR/handlers-list)[ Packagist](https://packagist.org/packages/flying/handlers-list)[ RSS](/packages/flying-handlers-list/feed)WikiDiscussions master Synced 2d ago

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

Generic list of arbitrary handlers
==================================

[](#generic-list-of-arbitrary-handlers)

[![Build Status](https://camo.githubusercontent.com/04bc4f722bed4b896386ba3f47db770d18b66b6846be2b23318532f6263141d7/68747470733a2f2f7472617669732d63692e6f72672f466c79696e6744522f68616e646c6572732d6c6973742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/FlyingDR/handlers-list) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/7e3db14556a88a04c0e6a43a4dd249e3c191de02f95b4eb1464ffd2c8a255868/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f466c79696e6744522f68616e646c6572732d6c6973742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/FlyingDR/handlers-list/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/268b6c1c3bdcd01a70e1062f60f2f6516ba8fade29d2a88039089b666829dc6c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f466c79696e6744522f68616e646c6572732d6c6973742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/FlyingDR/handlers-list/?branch=master)

This very simple library provides implementation of generic list of arbitrary handlers.

Its primary goal is to simplify process of organizing multiple related objects into iterable list of handlers with:

1. Ensuring type correctness by providing class constraint, handlers need to implement / extend
2. Support for defining handlers priority

### Requirements

[](#requirements)

No dependencies are required, just PHP 7.4 or 8.x.

### Example

[](#example)

```
interface MyHandler {
    public function doSomething(): void;
}

class Foo implements MyHandler {

}

class Bar implements MyHandler {

}

class Baz extends Bar {

}

// Creating list of handlers
$handlers = new HandlersList([
    new Foo(),
    new Bar(),
    new Baz(),
], MyHandler::class);

// ... later in code ...
foreach($handlers as $handler) {
    // We can be sure that $handler is of type MyHandler::class
    $handler->doSomething();
}
```

In a case if some handler implements `PrioritizedHandlerInterface` - its priority is considered:

```
interface MyHandler {
    public function name(): string;
}

class A implements MyHandler {
    public function name(): string {
        return 'A';
    }
}

class B implements MyHandler, PrioritizedHandlerInterface {
    public function name(): string {
        return 'B';
    }

    public function getHandlerPriority(): int {
        return 10;
    }
}

$handlers = new HandlersList([
    new A(),
    new B(),
], MyHandler::class);

foreach($handlers as $handler) {
    echo $handler->name() . ' ';
}
```

Example above will output `B A` because `B` have higher priority then `A` despite the fact that it was put later in the list of handlers.

### Methods

[](#methods)

It is, of course, possible to modify list of handlers:

- `set()` - set new list of handlers
- `add()` - add a new handler to the list
- `remove()` - remove given handler from the list
- `clear()` - remove all handlers from the list

There is also several methods for inspecting list of handlers:

- `isEmpty()` - check if handlers list is empty
- `count()` - get number of handlers in the list
- `accepts()` - check if list accepts a given object or objects of given cass
- `contains()` - check if given handler is available in the list
- `filter()` - filter handlers list using provided test callable and return array of matching handlers
- `find()` - searches for a handler using provided callable
- `getIterator()` - get handlers from the list as iterator
- `toArray()` - get handlers from the list as array

And remaining methods:

- `getConstraint()` - get class constraint that is applied to handlers in this list

### Immutable handlers list

[](#immutable-handlers-list)

Besides default, mutable implementation of handlers list there is also immutable version: `ImmutableHandlersList`. Its functionality is completely same in except of list modification methods that returns new copy of the list instead of modifying original one.

### License

[](#license)

MIT License

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity70

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

Every ~493 days

Total

3

Last Release

1902d ago

Major Versions

v1.0.0 → v2.0.02018-06-17

v2.0.0 → v3.0.02021-02-26

PHP version history (2 changes)v1.0.0PHP &gt;=7.1

v3.0.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2219fdfdf70c7118270dfa18596299660a51d4cced164e98d139dd03b3579128?d=identicon)[Flying](/maintainers/Flying)

---

Top Contributors

[![FlyingDR](https://avatars.githubusercontent.com/u/822673?v=4)](https://github.com/FlyingDR "FlyingDR (17 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/flying-handlers-list/health.svg)

```
[![Health](https://phpackages.com/badges/flying-handlers-list/health.svg)](https://phpackages.com/packages/flying-handlers-list)
```

PHPackages © 2026

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