/** * check book collection at next index * * @return bool */ public function hasNext() { if ($this->index < $this->bookShelf->getLength()) { return true; } else { return false; } }
/** * BookShelfReverseIterator constructor. * @param BookShelf $bookShelf */ public function __construct(BookShelf $bookShelf) { $this->bookShelf = $bookShelf; $this->index = $this->bookShelf->getLength() - 1; }