_notesById = array(); $this->_notesByTitle = array(); foreach ($data->notes as $note) { $note = new Zend_Service_RememberTheMilk_Note($note); $this->_notesById[$note->getId()] = $note; $this->_notesByTitle[$note->getTitle()] = $note; } } /** * Implementation of IteratorAggregate::getIterator(). * * @return ArrayIterator */ public function getIterator() { return new ArrayIterator($this->_notesById); } /** * Implementation of IteratorAggregate::getLength(). * * @return int */ public function getLength() { return count($this->_notesById); } /** * Returns the note instance with the specified identifier. * * @param int $id Note identifier * @return Zend_Service_RememberTheMilk_Note */ public function getNoteById($id) { return $this->_notesById[$id]; } /** * Returns the note instance with the specified title. * * @param string $title Note title * @return Zend_Service_RememberTheMilk_Note */ public function getNoteByTitle($title) { return $this->_notesByTitle[$title]; } }