org_heigl / trait-iterator
A Trait for the iterator-interface
1.1.0
2016-09-29 18:45 UTC
Requires (Dev)
- phpunit/phpunit: ^5.5
This package is auto-updated.
Last update: 2026-02-23 12:39:21 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.