承接 componenta/priority-list 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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:

  • IteratorAggregate
  • Countable
  • Componenta\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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固