$this->students[] = $student; } } public function contains(Student $student) { foreach ($this->students as $s) { if ($s->getId() == $student->getId()) { return true; } } return false; } public function getIterator() { return new CachingIterator($this->students->getIterator(), true); } } $students = new StudentList(); $students->add(new Student('01234123', 'Joe')); $students->add(new Student('00000014', 'Bob')); $students->add(new Student('00000014', 'Foo')); // The goal is to verify we can access the cached string value even if it was // generated by a call to __toString(). To check this we need to access the // iterator's __toString() method. $it = $students->getIterator(); foreach ($it as $student) { echo $it->__toString(), "\n"; } ?> ===DONE===