/** * Converts this iterator into an instance of Morph_Collection * * Note that this means all objects will be held in memory so * you need to be a bit careful not to exceed memory limits * * @return Morph_Collection */ public function toCollection() { $collection = new Collection(); $collection->setPermissableType(\get_class($this->type)); $collection->setTotalCount($this->totalCount()); $this->rewind(); foreach ($this as $object) { $collection->append($object); } return $collection; }