mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-23 17:22:41 +01:00
24 lines
425 B
PHP
24 lines
425 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Behavioral\Iterator;
|
|
|
|
class BookListReverseIterator extends BookListIterator
|
|
{
|
|
|
|
public function __construct(BookList $bookList)
|
|
{
|
|
$this->bookList = $bookList;
|
|
$this->currentBook = $this->bookList->count() - 1;
|
|
}
|
|
|
|
public function next()
|
|
{
|
|
$this->currentBook--;
|
|
}
|
|
|
|
public function valid()
|
|
{
|
|
return 0 <= $this->currentBook;
|
|
}
|
|
}
|