diff --git a/Iterator/File.php b/Iterator/File.php index 0e1aa3d..e2e6a3d 100644 --- a/Iterator/File.php +++ b/Iterator/File.php @@ -3,21 +3,9 @@ namespace DesignPatterns\Iterator; /** - * iterator pattern - * - * Purpose: - * to make an object iterable - * - * 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 + * class File * * THIS EXAMPLE ALSO APPLIES THE COMPOSITE PATTERN - * */ class File { diff --git a/Iterator/README.md b/Iterator/README.md new file mode 100644 index 0000000..d364490 --- /dev/null +++ b/Iterator/README.md @@ -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