Skip to content

Commit 0251304

Browse files
author
Dominik Liebler
committed
README iterator
1 parent 1d166d4 commit 0251304

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

Iterator/File.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,9 @@
33
namespace DesignPatterns\Iterator;
44

55
/**
6-
* iterator pattern
7-
*
8-
* Purpose:
9-
* to make an object iterable
10-
*
11-
* Examples:
12-
* - to process a file line by line by just running over all lines (which have an object representation) for a file
13-
* (which of course is an object, too)
14-
*
15-
* Note:
16-
* Standard PHP Library (SPL) defines an interface Iterator which is best suited for this!
17-
* Often you would want to implement the Countable interface too, to allow count($object) on your iterable object
6+
* class File
187
*
198
* THIS EXAMPLE ALSO APPLIES THE COMPOSITE PATTERN
20-
*
219
*/
2210
class File
2311
{

Iterator/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Iterator
2+
3+
## Purpose
4+
5+
To make an object iterable and to make it appear like a collection of objects.
6+
7+
## Examples
8+
9+
* 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)
10+
11+
## Note
12+
13+
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

0 commit comments

Comments
 (0)