Skip to content

Commit

Permalink
Adding missing methods for PersonRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 9, 2014
1 parent 3c212f0 commit 5d2c907
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 2 deletions.
22 changes: 22 additions & 0 deletions examples/people/model/combined_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\PeopleRepository($client);
$person = $repository->getCombinedCredits(33);

var_dump($person);
22 changes: 22 additions & 0 deletions examples/people/model/movie_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\PeopleRepository($client);
$person = $repository->getMovieCredits(33);

var_dump($person);
22 changes: 22 additions & 0 deletions examples/people/model/tv_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\PeopleRepository($client);
$person = $repository->getTvCredits(33);

var_dump($person);
47 changes: 46 additions & 1 deletion lib/Tmdb/Api/People.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,52 @@ public function getPerson($person_id, array $parameters = array(), array $header
*/
public function getCredits($person_id, array $parameters = array(), array $headers = array())
{
return $this->get('person/' . $person_id . '/credits', $parameters, $headers);
return $this->getCombinedCredits($person_id, $parameters, $headers);
}

/**
* Get the movie credits for a specific person id.
*
* @param $person_id
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function getMovieCredits($person_id, array $parameters = array(), array $headers = array())
{
return $this->get('person/' . $person_id . '/movie_credits', $parameters, $headers);
}

/**
* Get the TV credits for a specific person id.
*
* To get the expanded details for each record, call the /credit method with the provided credit_id.
* This will provide details about which episode and/or season the credit is for.
*
* @param $person_id
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function getTvCredits($person_id, array $parameters = array(), array $headers = array())
{
return $this->get('person/' . $person_id . '/tv_credits', $parameters, $headers);
}

/**
* Get the combined (movie and TV) credits for a specific person id.
*
* To get the expanded details for each TV record, call the /credit method with the provided credit_id.
* This will provide details about which episode and/or season the credit is for.
*
* @param $person_id
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function getCombinedCredits($person_id, array $parameters = array(), array $headers = array())
{
return $this->get('person/' . $person_id . '/combined_credits', $parameters, $headers);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion lib/Tmdb/Factory/PeopleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ public function __construct()
}

/**
* {@inheritdoc}
* @param array $data
* @param Person\AbstractMember|null $person
*
* @return Person|CrewMember|CastMember
*/
public function create(array $data = array(), Person\AbstractMember $person = null)
{
Expand Down
54 changes: 54 additions & 0 deletions lib/Tmdb/Repository/PeopleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,60 @@ public function load($id, array $parameters = array(), array $headers = array())
return $this->getFactory()->create($data);
}

/**
* Get the movie credits for a specific person id.
*
* @param $id
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getMovieCredits($id, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getMovieCredits($id, $this->parseQueryParameters($parameters), $headers);
$person = $this->getFactory()->create(array('movie_credits' => $data));

return $person->getMovieCredits();
}

/**
* Get the TV credits for a specific person id.
*
* To get the expanded details for each record, call the /credit method with the provided credit_id.
* This will provide details about which episode and/or season the credit is for.
*
* @param $id
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getTvCredits($id, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getTvCredits($id, $this->parseQueryParameters($parameters), $headers);
$person = $this->getFactory()->create(array('tv_credits' => $data));

return $person->getTvCredits();
}

/**
* Get the combined (movie and TV) credits for a specific person id.
*
* To get the expanded details for each TV record, call the /credit method with the provided credit_id.
* This will provide details about which episode and/or season the credit is for.
*
* @param $id
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getCombinedCredits($id, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getCombinedCredits($id, $this->parseQueryParameters($parameters), $headers);
$person = $this->getFactory()->create(array('combined_credits' => $data));

return $person->getCombinedCredits();
}

/**
* Return the related API class
*
Expand Down

0 comments on commit 5d2c907

Please sign in to comment.