mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-10 17:04:01 +02:00
Changes to take care of unwanted (negative) indices
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user