PHPackages                             purrphp/uuid-collection - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. purrphp/uuid-collection

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

purrphp/uuid-collection
=======================

Type-safe uuid collections for PHP with rich functions

1.0.0(3mo ago)10MITPHPPHP ^8.1CI passing

Since Mar 30Pushed 3mo agoCompare

[ Source](https://github.com/PurrPHP/uuid-collection)[ Packagist](https://packagist.org/packages/purrphp/uuid-collection)[ Docs](https://github.com/PurrPHP/uuid-collection)[ RSS](/packages/purrphp-uuid-collection/feed)WikiDiscussions master Synced 3w ago

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

PurrPHP/Uuid collection
=======================

[](#purrphpuuid-collection)

Type-safe uuid collections for PHP 8.

### About

[](#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](https://github.com/PurrPHP/pure-collection).

Inspired by [Kotlin collections](https://kotlinlang.org/docs/collections-overview.html), 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
-----------------

[](#available-classes)

ClassDescription`UuidList`Ordered list of uuids`UuidMap`Associative (key → UuidInterface) map`UuidSet`Ordered list of unique UuidInterfaceInstallation
------------

[](#installation)

```
composer require purrphp/uuid-collection
```

Usage
-----

[](#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](src/UuidCollectionTrait.php).

All collections are immutable and return new object after changes.

#### Creating

[](#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

[](#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

[](#sorting)

```
$sorted     = $list->sortedByValue();           // ascending (lexicographic)
$descSorted = $list->sortedByValue(desc: true); // descending
```

#### Set operations

[](#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

[](#adding-and-removing-elements)

```
$updated = $list->add($uuid4, $uuid5);    // returns new instance
$trimmed = $list->remove($uuid1, $uuid2); // returns new instance
```

### Common Operations

[](#common-operations)

All collections implement `CollectionInterface` from PurrPHP Pure Collection. See the full reference:

- [Common Methods](https://github.com/PurrPHP/pure-collection/blob/master/docs/common-methods.md) — searching, filtering, transforming, grouping, sizing, iteration

Development
-----------

[](#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

[](#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
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance82

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

90d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5460215?v=4)[Aleksey M](/maintainers/don-tre)[@don-tre](https://github.com/don-tre)

---

Tags

phpmapsetlistimmutabledata structurestype-safeuuid-collection

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/purrphp-uuid-collection/health.svg)

```
[![Health](https://phpackages.com/badges/purrphp-uuid-collection/health.svg)](https://phpackages.com/packages/purrphp-uuid-collection)
```

###  Alternatives

[phpcollection/phpcollection

General-Purpose Collection Library for PHP

96864.5M34](/packages/phpcollection-phpcollection)[equip/structure

Simple, immutable data structures

40202.3k5](/packages/equip-structure)[chdemko/sorted-collections

Sorted Collections for PHP &gt;= 8.4

222.6M3](/packages/chdemko-sorted-collections)

PHPackages © 2026

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