_tasks = array(); if (is_array($data->task)) { foreach ($data->task as $task) { $task = new Zend_Service_RememberTheMilk_Task($task); $this->_tasksById[$task->getId()] = $task; } } else { $task = new Zend_Service_RememberTheMilk_Task($data->task); $this->_tasksById[$task->getId()] = $task; } } /** * Implementation of IteratorAggregate::getIterator(). * * @return ArrayIterator */ public function getIterator() { return new ArrayIterator($this->_tasksById); } /** * Implementation of IteratorAggregate::getLength(). * * @return int */ public function getLength() { return count($this->_tasksById); } /** * Returns the task instance with the specified identifier. * * @param int $id Task identifier */ public function getTaskById($id) { return $this->_tasksById[$id]; } }