PHPackages                             naoyuki42/php-keyed-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. naoyuki42/php-keyed-collection

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

naoyuki42/php-keyed-collection
==============================

A PHP library that provides a keyed collection class with type safety and immutability.

0.1.0(7mo ago)00[1 PRs](https://github.com/naoyuki42/php-keyed-collection/pulls)MITPHPPHP &gt;=8.4CI passing

Since Oct 5Pushed 3mo agoCompare

[ Source](https://github.com/naoyuki42/php-keyed-collection)[ Packagist](https://packagist.org/packages/naoyuki42/php-keyed-collection)[ RSS](/packages/naoyuki42-php-keyed-collection/feed)WikiDiscussions master Synced 1mo ago

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

php-keyed-collection
====================

[](#php-keyed-collection)

Overview
--------

[](#overview)

`php-keyed-collection` is a PHP library that provides a type-safe and immutable keyed collection class. It supports keys and values of any type, including arrays, objects, and null.

Features
--------

[](#features)

- Support for keys of any type (string, int, float, bool, array, object, null, etc.)
- Methods for getting, setting, deleting, checking existence, clearing, and iterating values
- Implements `Countable` and `Iterator` interfaces for `foreach` and `count()` support
- Readonly `size` property for getting the number of elements

Installation
------------

[](#installation)

```
composer require naoyuki42/php-keyed-collection
```

Usage
-----

[](#usage)

```
use Naoyuki42\KeyedCollection\Map;

$map = new Map();

// Setting values
$map->set('key1', 'value1');
$map->set(123, 'value2');
$map->set([1,2], 'value3');
$obj = new stdClass();
$map->set($obj, 'value4');

// Getting values
echo $map->get('key1'); // value1
echo $map->get(123);    // value2

// Checking existence
var_dump($map->has([1,2])); // true

// Deleting values
$map->delete('key1');

// Getting size
echo $map->size; // 3

// Clearing all entries
$map->clear();

// Iteration
foreach ($map as $key => $value) {
    var_dump($key, $value);
}
```

License
-------

[](#license)

MIT

[日本語のREADME](README.ja.md)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance78

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

210d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/398d463470353df6302e04cf3e0bfcd6806e029da87bbce6b9abecb71437f7dd?d=identicon)[naoyuki42](/maintainers/naoyuki42)

---

Top Contributors

[![naoyuki42](https://avatars.githubusercontent.com/u/70516149?v=4)](https://github.com/naoyuki42 "naoyuki42 (18 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/naoyuki42-php-keyed-collection/health.svg)

```
[![Health](https://phpackages.com/badges/naoyuki42-php-keyed-collection/health.svg)](https://phpackages.com/packages/naoyuki42-php-keyed-collection)
```

PHPackages © 2026

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