Skip to content

Commit

Permalink
Fixing bug in the filterId() method, releasing 2.0.5.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Mar 26, 2015
1 parent d2c9d69 commit 4816554
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Tmdb/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/';
Expand Down
10 changes: 7 additions & 3 deletions lib/Tmdb/Model/Common/GenericCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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());
}

/**
Expand Down

0 comments on commit 4816554

Please sign in to comment.