Skip to content

Commit

Permalink
Adding missing methods in MovieRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 9, 2014
1 parent 8acddbb commit 3c212f0
Show file tree
Hide file tree
Showing 17 changed files with 503 additions and 16 deletions.
22 changes: 22 additions & 0 deletions examples/movies/model/alternative_titles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\MovieRepository($client);
$collection = $repository->getAlternativeTitles(87421);

var_dump($collection);
22 changes: 22 additions & 0 deletions examples/movies/model/changes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\MovieRepository($client);
$collection = $repository->getChanges(87421);

var_dump($collection);
22 changes: 22 additions & 0 deletions examples/movies/model/credits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\MovieRepository($client);
$collection = $repository->getCredits(87421);

var_dump($collection);
22 changes: 22 additions & 0 deletions examples/movies/model/images.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\MovieRepository($client);
$collection = $repository->getImages(87421);

var_dump($collection);
22 changes: 22 additions & 0 deletions examples/movies/model/keywords.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\MovieRepository($client);
$collection = $repository->getKeywords(87421);

var_dump($collection);
22 changes: 22 additions & 0 deletions examples/movies/model/lists.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\MovieRepository($client);
$collection = $repository->getLists(87421);

var_dump($collection);
22 changes: 22 additions & 0 deletions examples/movies/model/releases.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\MovieRepository($client);
$collection = $repository->getReleases(87421);

var_dump($collection);
22 changes: 22 additions & 0 deletions examples/movies/model/reviews.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\MovieRepository($client);
$collection = $repository->getReviews(87421);

var_dump($collection);
22 changes: 22 additions & 0 deletions examples/movies/model/similar_movies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\MovieRepository($client);
$collection = $repository->getSimilarMovies(87421);

var_dump($collection);
22 changes: 22 additions & 0 deletions examples/movies/model/trailers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\MovieRepository($client);
$collection = $repository->getTrailers(87421);

var_dump($collection);
6 changes: 3 additions & 3 deletions lib/Tmdb/Api/Movies.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ public function getAlternativeTitles($movie_id, array $parameters = array(), arr
}

/**
* Get the cast information for a specific movie id.
* Get the cast and crew information for a specific movie id.
*
* @param $movie_id
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function getCast($movie_id, array $parameters = array(), array $headers = array())
public function getCredits($movie_id, array $parameters = array(), array $headers = array())
{
return $this->get('movie/' . $movie_id . '/casts', $parameters, $headers);
return $this->get('movie/' . $movie_id . '/credits', $parameters, $headers);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions lib/Tmdb/Factory/ImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public function createImageCollection(array $data = array())
$collection = new Images();

foreach($data as $format => $formatCollection) {

if (!is_array($formatCollection)) {
continue;
}

foreach($formatCollection as $item) {
if (array_key_exists($format, Image::$_formats)) {
$item = $this->create($item, $format);
Expand Down
3 changes: 2 additions & 1 deletion lib/Tmdb/Factory/MovieFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public function __construct()
}

/**
* {@inheritdoc}
* @param array $data
* @return Movie
*/
public function create(array $data = array())
{
Expand Down
21 changes: 19 additions & 2 deletions lib/Tmdb/Repository/CollectionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@

class CollectionRepository extends AbstractRepository {

private $imageFactory;

public function __construct()
{
$this->imageFactory = new ImageFactory();
}

/**
* Load a collection with the given identifier
*
Expand Down Expand Up @@ -63,11 +70,21 @@ public function getFactory()
}

/**
* @return ImageFactory
* @param mixed $imageFactory
* @return $this
*/
public function setImageFactory($imageFactory)
{
$this->imageFactory = $imageFactory;
return $this;
}

/**
* @return mixed
*/
public function getImageFactory()
{
return new ImageFactory();
return $this->imageFactory;
}

/**
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 @@ -16,6 +16,7 @@
use Tmdb\Factory\MovieFactory;
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Company;
use Tmdb\Model\Movie;

class CompanyRepository extends AbstractRepository {

Expand All @@ -39,7 +40,7 @@ public function load($id, array $parameters = array(), array $headers = array())
* @param integer $id
* @param array $parameters
* @param array $headers
* @return Movie[]
* @return GenericCollection|Movie[]
*/
public function getMovies($id, array $parameters = array(), array $headers = array())
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Tmdb/Repository/KeywordRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Tmdb\Repository;

use Tmdb\Factory\KeywordFactory;
use Tmdb\Model\Collection\ResultCollection;
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Keyword;

Expand All @@ -37,7 +38,7 @@ public function load($id, array $parameters = array(), array $headers = array())
* @param $id
* @param array $parameters
* @param array $headers
* @return Keyword[]
* @return ResultCollection|Keyword[]
*/
public function getMovies($id, array $parameters = array(), array $headers = array()) {
return $this->getFactory()->createResultCollection(
Expand Down
Loading

0 comments on commit 3c212f0

Please sign in to comment.