purrphp/uuid-collection
Composer 安装命令:
composer require purrphp/uuid-collection
包简介
Type-safe uuid collections for PHP with rich functions
README 文档
README
Type-safe uuid collections for PHP 8.
About
This library provides flexible features to manage uuid collections (filter, factory methods, etc..) and strict clean structures.
It's based on PurrPHP Pure collections.
Inspired by Kotlin collections, the library provides three collection types:
Each type has an immutable (default) and a mutable variant (except set). Immutable methods return a new instance; mutable methods modify the instance in place and return $this.
Available Classes
| Class | Description |
|---|---|
UuidList |
Ordered list of uuids |
UuidMap |
Associative (key → UuidInterface) map |
UuidSet |
Ordered list of unique UuidInterface |
Installation
composer require purrphp/uuid-collection
Usage
All UUID collection classes implement UuidCollectionInterface, which extends CollectionInterface with UUID-specific factory methods, conversion methods, and set operations.
All common code placed in UuidCollectionTrait.php.
All collections are immutable and return new object after changes.
Creating
use Purr\UuidCollection\UuidList; // From UuidInterface objects $list = new UuidList($uuid1, $uuid2, $uuid3); // From UUID strings $list = UuidList::fromStrings( '550e8400-e29b-41d4-a716-446655440000', '6ba7b810-9dad-11d1-80b4-00c04fd430c8', ); // From raw bytes $list = UuidList::fromBytes($bytes1, $bytes2); // From a StringList / StringSet / StringMap $list = UuidList::fromStringCollection($stringList);
Converting
$list->toStringArray(); // ['550e8400-...', '6ba7b810-...'] $list->toBytesArray(); // ["\x55\x0e...", ...] $list->toInterfaceArray(); // [UuidInterface, ...] $list->toStringList(); // StringList of UUID strings $list->toStringSet(); // StringSet of UUID strings (unique) $list->toStringMap(); // StringMap of UUID strings
Sorting
$sorted = $list->sortedByValue(); // ascending (lexicographic) $descSorted = $list->sortedByValue(desc: true); // descending
Set operations
$a = new UuidSet($uuid1, $uuid2, $uuid3); $b = new UuidSet($uuid2, $uuid3, $uuid4); $a->diff($b)->toStringArray(); // UUIDs in $a but not in $b → [$uuid1] $a->intersect($b)->toStringArray(); // UUIDs present in both → [$uuid2, $uuid3]
Adding and removing elements
$updated = $list->add($uuid4, $uuid5); // returns new instance $trimmed = $list->remove($uuid1, $uuid2); // returns new instance
Common Operations
All collections implement CollectionInterface from PurrPHP Pure Collection. See the full reference:
- Common Methods — searching, filtering, transforming, grouping, sizing, iteration
Development
composer install composer test # Run tests composer analyse # Static analysis composer cs-check # Code style check composer cs-fix # Fix code style composer check # All checks
With Docker / Make
make test # Run tests make analyse # Static analysis make cs-check # Code style check make check # All checks make shell # Open shell in dev container
License
MIT — see LICENSE.
purrphp/uuid-collection 适用场景与选型建议
purrphp/uuid-collection 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「map」 「set」 「list」 「immutable」 「data-structures」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 purrphp/uuid-collection 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 purrphp/uuid-collection 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 purrphp/uuid-collection 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple, immutable data structures
Maps in minutes. Powered by the Google Maps API.
Yii2 map input widget. Allows you to select geographcal coordinates via a human-friendly inteface.
Baum is an implementation of the Nested Set pattern for Eloquent models.
A useful set of HTML and Form macros with css and js made for bootstrap
The enumeration type for PHP
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-30