org_heigl / trait-iterator
A Trait for the iterator-interface
Installs: 2 241
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 0
Requires (Dev)
- phpunit/phpunit: ^5.5
This package is auto-updated.
Last update: 2024-11-23 10:08:27 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.