ducatel/php-collection

PHP中数据结构实现

dev-master / 1.0.x-dev 2016-08-23 19:56 UTC

This package is not auto-updated.

Last update: 2024-09-26 02:24:02 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads StyleCI

此库为PHP添加了一些“标准”集合。集合类似于数组,但遵循约束

  • 类型化集合,只接受一种类型的变量
  • 排序集合,总是排序
  • 集合集合,不允许重复
  • 数组集合,允许重复

还可以找到一些针对非对象变量(如字符串或数字)的专用集合

安装

通过Composer

$ composer require ducatel/php-collection

用法

$stringArray = new Ducatel\PHPCollection\Specialized\StringArray();
$stringArray[] = "a"; // ['a']
$stringArray[] = "b"; // ['a', 'b']
$stringArray[] = new PDO(); // FAIL

$typedArray = new Ducatel\PHPCollection\TypedArray(MyClass::class);
$typedArray[] = new MyClass(); // OK
$typedArray[] = "a"; // FAIL

变更日志

请参阅 CHANGELOG 了解最近更改的详细信息。

测试

$ composer test

贡献

请参阅 CONTRIBUTINGCONDUCT 了解详细信息。

安全性

如果您发现任何安全问题,请通过电子邮件 david@ducatel.eu 而不是使用问题跟踪器。

致谢

许可

MIT许可(MIT)。请参阅 许可文件 了解更多信息。