dhii/iterator-interface

Interfaces for standard iterators

v0.1-alpha1 2018-04-24 19:28 UTC

This package is auto-updated.

Last update: 2024-10-07 03:22:59 UTC


README

Build Status Code Climate Test Coverage Latest Stable Version This package complies with Dhii standards

Details

An iterator standard, which aims to provide more information about each iteration by exposing an immutable iteration object. This object can be safely passed to other methods, even those which save the reference to it, as a new object is created for every iteration. That object can provide additional information besides the current key and value. This makes implementations of this standard easier to work with than other iterator implementations, such as DirectoryIterator, which expose iteration data through the iterator itself, instead of a separate object, making it hard to keep iteration data immutable. The fact that its manipulator methods are allowed to throw a specific type of exception make it possible to create more reliable consumers with meaningful error reporting.

Features

  • All standards-compliant iterators are PHP iterators.
  • Iteration information provided via immutable and extensible iteration objects.
  • Easier to keep track of iteration information: each iteration produces a separate iteration object.
  • Specialized iterator types can be created on interface level by promising custom iteration types.

Interfaces