Skip to content

Commit

Permalink
Verifying ResultCollections are present where they should be.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 26, 2014
1 parent 077f8e7 commit e13bb4b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/Tmdb/Factory/MovieFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ public function create(array $data = array())
}

if (array_key_exists('reviews', $data)) {
$movie->setReviews($this->getReviewFactory()->createCollection($data['reviews']));
$movie->setReviews($this->getReviewFactory()->createResultCollection($data['reviews']));
}

if (array_key_exists('lists', $data)) {
$movie->setLists($this->getListItemFactory()->createCollection($data['lists']));
$movie->setLists($this->getListItemFactory()->createResultCollection($data['lists']));
}

if (array_key_exists('changes', $data)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Tmdb/Repository/ChangesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ChangesRepository extends AbstractRepository {
public function getMovieChanges(ChangesQuery $query, array $headers = array()) {
$data = $this->getApi()->getMovieChanges($query->toArray(), $headers);

return $this->getFactory()->createCollection($data);
return $this->getFactory()->createResultCollection($data);
}

/**
Expand All @@ -59,7 +59,7 @@ public function getMovieChanges(ChangesQuery $query, array $headers = array()) {
public function getPeopleChanges(ChangesQuery $query, array $headers = array()) {
$data = $this->getApi()->getPersonChanges($query->toArray(), $headers);

return $this->getFactory()->createCollection($data);
return $this->getFactory()->createResultCollection($data);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/Tmdb/Repository/CompanyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use Tmdb\Factory\CompanyFactory;
use Tmdb\Factory\MovieFactory;
use Tmdb\Model\Collection\ResultCollection;
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Company;
use Tmdb\Model\Movie;
Expand Down Expand Up @@ -87,7 +88,7 @@ public function getMovieFactory()
* @return Movie[]
*/
public function createMovieCollection($data){
$collection = new GenericCollection();
$collection = new ResultCollection();

if (array_key_exists('results', $data)) {
$data = $data['results'];
Expand Down
4 changes: 2 additions & 2 deletions lib/Tmdb/Repository/MovieRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public function getLatest(array $options = array())
*/
public function getUpcoming(array $options = array())
{
return $this->createCollection(
return $this->getFactory()->createResultCollection(
$this->getApi()->getUpcoming($options)
);
}
Expand All @@ -295,7 +295,7 @@ public function getUpcoming(array $options = array())
*/
public function getNowPlaying(array $options = array())
{
return $this->createCollection(
return $this->getFactory()->createResultCollection(
$this->getApi()->getNowPlaying($options)
);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Tmdb/Repository/PeopleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* Class PeopleRepository
* @package Tmdb\Repository
* @see http://docs.themoviedb.apiary.io/#people
*
* @todo implement the new methods
*/
class PeopleRepository extends AbstractRepository {
/**
Expand Down
6 changes: 6 additions & 0 deletions lib/Tmdb/Repository/SearchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ public function searchKeyword($query, KeywordSearchQuery $parameters, array $hea
return $this->getKeywordFactory()->createResultCollection($data);
}

/**
* Convert parameters back to an array
*
* @param array $parameters
* @return array
*/
private function getParameters($parameters = array()) {
if ($parameters instanceof SearchQuery) {
return $parameters->toArray();
Expand Down
12 changes: 0 additions & 12 deletions lib/Tmdb/Repository/TvRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,4 @@ public function getOnTheAir(array $options = array())
$this->getApi()->getTopRated($options)
);
}

/**
* Create an collection of an array
*
* @todo Allow an array of Tv objects to pass ( custom collection )
*
* @param $data
* @return Tv[]
*/
private function createCollection($data){
return $this->getFactory()->createCollection($data);
}
}

0 comments on commit e13bb4b

Please sign in to comment.