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: 2024-10-23 09:58:25 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.