承接 hampom/bari-kata 相关项目开发

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

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

hampom/bari-kata

最新稳定版本:0.0.2

Composer 安装命令:

composer require hampom/bari-kata

包简介

Map

README 文档

README

🍜 型安全・配列禁止を徹底した PHP コレクションライブラリ 「BariKata」は TypedCollection を中心に設計され、プラグイン拡張やファクトリーによる標準セット化が可能です。

特徴

  • 型安全なコレクション
    指定したクラス以外は格納できません。 ArrayAccess で自然に操作可能。
  • プラグイン拡張
    map, filter, orderBy などの操作を簡単に追加できます。
  • Factory
    あらかじめ定義したプラグインセットを有効化した状態でコレクションを生成可能。

インストール

composer require hampom/bari-kata

使い方

TypedCollection の生成

use Hampom\BariKata\TypedCollection;

$ids = new TypedCollection('int');
$ids[] = 1;
$ids[] = 2;

// -> InvalidArgumentException: Value must be of type int, string given.
// $ids[] = 'a';

プラグインの追加

use Hampom\BariKata\TypedCollection;
use Hampom\BariKata\Plugins\toArray;

$ids = new TypedCollection('int', [0], [new toArray]);
$ids[] = 1;

// -> array(0 => 0, 1 => 1)
var_export($ids->toArray());

ファクトリーの利用

final class IntCollectionFactory extends TypedCollectionFactory
{
    protected static string $type = 'int';

    protected static function plugins(): array
    {
        return [
            ["class" => toArray::class]
        ];
    }
}

$ids = (new IntCollectionFactory)->factory([0]);
$ids[] = 1;

// -> array(0 => 0, 1 => 1)
var_export($ids->toArray());

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-14