org_heigl/trait-iterator

A Trait for the iterator-interface

1.1.0 2016-09-29 18:45 UTC

This package is auto-updated.

Last update: 2020-07-23 00:43:46 UTC


README

Often used implementation of the IteratorInterface

Installation

composer require org_heigl/trait-iterator

Usage

Add it to a class like this:

use Org_Heigl\IteratorTrait\IteratorTrait;

class MyList implements \Iterator
{
    use IteratorTrait;

    /** Can be an array or an Object implementing traversable */
    protected $yourArrayToIterateOver = [];

    public function & getIterableElement()
    {
        return $yourArrayToIterateOver
    }
}

The rest of the Iterator implementation is handled within the IteratorTrait.

Issues

Feel free to drop an issue on github when you need help.