Introduction
Iterator Aggregation allows you to develop without rewriting a lot of the same code for classes. It is simple to implement with only one method in the interface. The method getIterator must return an Iterator object for it to work in foreach.
Interface
interface IteratorAggregate
{
function getIterator();
}
Example
You can aggregate to PHP extensions that implement a iterator object. If you need to pass XML, you can create a new SimpleXML class giving XML iteration without having to implement it yourself.
class XmlPageViewer implements IteratorAggregate
{
// My Methods here
public function getIterator()
{
return new SimpleXMLElement($this->xml);
}
}
Possibly Related Posts:
- Bullet: E-Book Library Management and Content Server
- Using ZendFramework 2 beta1 For Directory Project
- The Way of Kings and Cosmere Theory
- “In Time” Movie Premise Flawed
- Completing HTTP Library For PHP
Comments are closed.