ramsondon/arraycollectionfactory

此软件包最新版本(v1.0)没有可用的许可信息。

通过类型提示生成类型安全的数组保存生成器

v1.0 2014-08-19 10:56 UTC

This package is not auto-updated.

Last update: 2024-09-24 07:57:42 UTC


README

ArrayCollectionFactory 是一个用于通过类型提示动态生成类型安全的 ArrayCollection 的 PHP 集合生成器。

ArrayCollection 实现 \Countable, \Iterator,动态创建的缓存 ArrayCollection 包含以下方法

->append(Class\of\Object $object);

->getAt($index);

->removeAt($index);

try phpunit in directory src/Ramsondon/TypedArray/Test to generate cached ArrayCollection and Interface.
the cached files will be created in src/Ramsondon/TypedArray/Cache

如何使用

    use Ramsondon\ArrayCollectionFactory;

    $factroy = new ArrayCollectionFactory();

    /* @var $collection \Ramsondon\TypedArray\Cache\ITestObjectArrayCollection */
    $collection = $factory->create('Class\\Of\\TestObject');

    $object = new Class\Of\TestObject();

    $collection->append($object);

    /* @var $testobject \Class\Of\TestObject */
    foreach ($collection as $testobject) {
        $testobject->doSomething();
    }