elements[] = null === $caption ? $element : new CaptionedSlide( $element, $caption ); return $cloned_list; } /** * Gets an iterator with the elements. * * This together with the IteratorAggregate turns the object into a "Traversable", * so you can just foreach over it and receive its elements in the correct type. * * @return ArrayIterator An iterator with the elements. */ public function getIterator() { return new ArrayIterator( $this->elements ); } /** * Gets the count of the elements. * * @return int The number of elements. */ public function count() { return count( $this->elements ); } }