Skip to content

Commit 4816554

Browse files
committed
Fixing bug in the filterId() method, releasing 2.0.5.
1 parent d2c9d69 commit 4816554

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/Tmdb/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Client
3131
use ApiMethodsTrait;
3232

3333
/** Client Version */
34-
const VERSION = '2.0.4';
34+
const VERSION = '2.0.5';
3535

3636
/** Base API URI */
3737
const TMDB_URI = 'api.themoviedb.org/3/';

lib/Tmdb/Model/Common/GenericCollection.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ public function offsetUnset($offset)
317317
*/
318318
public function filterId($id)
319319
{
320+
if (1 === count($this->data)) {
321+
return array_shift($this->data);
322+
}
323+
320324
$result = $this->filter(
321325
function ($key, $value) use ($id) {
322326
if ($value->getId() == $id) {
@@ -325,11 +329,11 @@ function ($key, $value) use ($id) {
325329
}
326330
);
327331

328-
if ($result && 1 === count($result)) {
329-
return array_shift($this->data);
332+
if (!count($result)) {
333+
return null;
330334
}
331335

332-
return null;
336+
return array_shift($result->getAll());
333337
}
334338

335339
/**

0 commit comments

Comments
 (0)