diff --git a/lib/Tmdb/Client.php b/lib/Tmdb/Client.php index d7d4a73f..97d30db5 100644 --- a/lib/Tmdb/Client.php +++ b/lib/Tmdb/Client.php @@ -31,7 +31,7 @@ class Client use ApiMethodsTrait; /** Client Version */ - const VERSION = '2.0.4'; + const VERSION = '2.0.5'; /** Base API URI */ const TMDB_URI = 'api.themoviedb.org/3/'; diff --git a/lib/Tmdb/Model/Common/GenericCollection.php b/lib/Tmdb/Model/Common/GenericCollection.php index 23ba6d88..6d8dabc9 100644 --- a/lib/Tmdb/Model/Common/GenericCollection.php +++ b/lib/Tmdb/Model/Common/GenericCollection.php @@ -317,6 +317,10 @@ public function offsetUnset($offset) */ public function filterId($id) { + if (1 === count($this->data)) { + return array_shift($this->data); + } + $result = $this->filter( function ($key, $value) use ($id) { if ($value->getId() == $id) { @@ -325,11 +329,11 @@ function ($key, $value) use ($id) { } ); - if ($result && 1 === count($result)) { - return array_shift($this->data); + if (!count($result)) { + return null; } - return null; + return array_shift($result->getAll()); } /**