Skip to content

Commit

Permalink
Fixing issue when the response from TMDB is null.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Mar 26, 2014
1 parent 7cd5ea2 commit ef7af10
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/Tmdb/Factory/AbstractFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ abstract public function createCollection(array $data = array());
* @param $class
* @return GenericCollection
*/
protected function createGenericCollection(array $data, $class)
protected function createGenericCollection($data = array(), $class)
{
if (is_object($class)) {
$class = get_class($class);
}

$collection = new GenericCollection();

if (null === $data) {
return $collection;
}

foreach ($data as $item) {
$collection->add(null, $this->hydrate(new $class(), $item));
}
Expand All @@ -68,10 +72,14 @@ protected function createGenericCollection(array $data, $class)
* @param string $method
* @return ResultCollection
*/
public function createResultCollection(array $data = array(), $method = 'create')
public function createResultCollection($data = array(), $method = 'create')
{
$collection = new ResultCollection();

if (null === $data) {
return $collection;
}

if (array_key_exists('page', $data)) {
$collection->setPage($data['page']);
}
Expand Down

0 comments on commit ef7af10

Please sign in to comment.