Download the PHP package componenta/priority-list without Composer
On this page you can find all versions of the php package componenta/priority-list. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download componenta/priority-list
More information about componenta/priority-list
Files in componenta/priority-list
Package priority-list
Short Description Priority ordered list with optional value validation
License MIT
Informations about the package priority-list
Componenta Priority List
Priority-ordered collection with optional value validation.
Use it for middleware lists, resolver chains, event listeners, plugin hooks, and any ordered registry where equal priorities must keep insertion order.
Installation
Related Packages
This package is standalone.
| Package | Why it may be used nearby |
|---|---|
componenta/event |
Event listener priority uses the same ordering model. |
componenta/pipeline |
Middleware lists can be ordered before pipeline construction. |
componenta/di |
Resolver/provider chains can be registered with priorities. |
Usage
The default order is descending priority. Equal priorities keep insertion order.
Validation
Factory methods restrict accepted values:
ofStrings()ofInts()ofFloats()ofBools()ofArrays()ofObjects()ofCallables()of(SomeClass::class)
Custom validators can be passed to the constructor. Rejected values throw InvalidArgumentException on insert().
Iteration
PriorityList implements:
IteratorAggregateCountableComponenta\Arrayable\Arrayable
Iteration sorts lazily. The list marks itself dirty on insert/order changes and sorts only before iteration, extraction, or each().
getIterator() yields priority as key by default. toArray() returns items with both value and priority.
Mutability
The collection is mutable. Methods such as insert, asc, desc, order, and clear mutate the current list and return it for fluent usage.