componenta/priority-list
Composer 安装命令:
composer require componenta/priority-list
包简介
Priority ordered list with optional value validation
README 文档
README
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
composer require componenta/priority-list
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
use Componenta\Stdlib\PriorityList; $list = PriorityList::ofStrings() ->insert('low', 10) ->insert('high', 100); $list->extract(); // "high"
The default order is descending priority. Equal priorities keep insertion order.
$list->asc(); // lowest priority first $list->desc(); // highest priority first
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.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-14