wearesho-team/base-collection

基于ArrayObject的泛型集合

1.0.2 2022-12-01 12:40 UTC

README

PHP Composer Latest Stable Version Total Downloads codecov

泛型集合的实现。

安装

composer require wearesho-team/base-collection

用法

创建你的类集合并实现type()方法。

它必须返回声明的(存在的)类名

<?php

use Wearesho\BaseCollection;

class MyCollection extends BaseCollection
{
    public function type(): string
    {
        return stdClass::class;
    }
}

现在你有了泛型集合!

如果你尝试添加非你类型实例的项,你将捕获到InvalidArgumentException

作者

许可证

MIT