Skip to content

Latest commit

 

History

History
21 lines (15 loc) · 916 Bytes

File metadata and controls

21 lines (15 loc) · 916 Bytes

Iterator design pattern in PHP

Iterator design pattern is a software design pattern which provides access to the elements of an aggregate object sequentially without exposing its underlying representation. It makes elements appear as a collection of objects.

  • Promote to "full object status" the traversal of a collection.
  • Polymorphic traversal

PHP implementations

  • PHP offers Iterator interface out of the box. Its SPL library has also a wide variety of useful iterators. After understanding the basics of the iterator pattern using these instead of reinventing the wheel is more convenient.

See also