mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-10-04 18:21:52 +02:00
README iterator
This commit is contained in:
13
Iterator/README.md
Normal file
13
Iterator/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Iterator
|
||||
|
||||
## Purpose
|
||||
|
||||
To make an object iterable and to make it appear like a collection of objects.
|
||||
|
||||
## Examples
|
||||
|
||||
* to process a file line by line by just running over all lines (which have an object representation) for a file (which of course is an object, too)
|
||||
|
||||
## Note
|
||||
|
||||
Standard PHP Library (SPL) defines an interface Iterator which is best suited for this! Often you would want to implement the Countable interface too, to allow `count($object)` on your iterable object
|
Reference in New Issue
Block a user