承接 naoyuki42/php-keyed-collection 相关项目开发

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

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

naoyuki42/php-keyed-collection

最新稳定版本:0.1.0

Composer 安装命令:

composer require naoyuki42/php-keyed-collection

包简介

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

README 文档

README

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

  • 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

composer require naoyuki42/php-keyed-collection

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

MIT

日本語のREADME

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-11