Changes to take care of unwanted (negative) indices

This commit is contained in:
Nils Rückmann
2015-09-07 02:17:17 +02:00
parent 367e5c0a20
commit c6f9dccff1
3 changed files with 8 additions and 7 deletions

View File

@@ -9,7 +9,7 @@ class BookList implements \Countable
public function getBook($bookNumberToGet)
{
if ((int)$bookNumberToGet <= $this->count()) {
if (isset($this->books[$bookNumberToGet])) {
return $this->books[$bookNumberToGet];
}