Skip to content

Files

Latest commit

author
Dominik Liebler
Sep 24, 2013
0251304 · Sep 24, 2013

History

History
This branch is 1058 commits behind DesignPatternsPHP/DesignPatternsPHP:main.

Iterator

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 24, 2013
Sep 24, 2013
Sep 21, 2013
Sep 21, 2013

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