forked from php-tmdb/api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa7bad2
commit 32281b9
Showing
6 changed files
with
354 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?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); | ||
|
||
$certificationRepository = new \Tmdb\Repository\CertificationRepository($client); | ||
$certificationList = $certificationRepository->getMovieList(); | ||
|
||
var_dump($certificationList); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?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 | ||
*/ | ||
namespace Tmdb\Factory; | ||
|
||
use Tmdb\Model\Certification; | ||
use Tmdb\Model\Common\GenericCollection; | ||
|
||
class CertificationFactory extends AbstractFactory | ||
{ | ||
/** | ||
* @param array $data | ||
* | ||
* @return Certification | ||
*/ | ||
public function create(array $data = array()) | ||
{ | ||
return $this->hydrate(new Certification\CountryCertification(), $data); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createCollection(array $data = array()) | ||
{ | ||
if (array_key_exists('certifications', $data)) { | ||
$data = $data['certifications']; | ||
} | ||
|
||
$collection = new GenericCollection(); | ||
|
||
foreach($data as $country => $certifications) { | ||
$certification = new Certification(); | ||
$certification->setCountry($country); | ||
|
||
foreach($certifications as $countryCertification) { | ||
$object = $this->create($countryCertification); | ||
|
||
$certification->getCertifications()->add(null, $object); | ||
} | ||
|
||
$collection->add(null, $certification); | ||
} | ||
|
||
return $collection; | ||
} | ||
|
||
/** | ||
* @param \Tmdb\Factory\TvEpisodeFactory $tvEpisodeFactory | ||
* @return $this | ||
*/ | ||
public function setTvEpisodeFactory($tvEpisodeFactory) | ||
{ | ||
$this->tvEpisodeFactory = $tvEpisodeFactory; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return \Tmdb\Factory\TvEpisodeFactory | ||
*/ | ||
public function getTvEpisodeFactory() | ||
{ | ||
return $this->tvEpisodeFactory; | ||
} | ||
|
||
/** | ||
* @param \Tmdb\Factory\TvSeasonFactory $tvSeasonFactory | ||
* @return $this | ||
*/ | ||
public function setTvSeasonFactory($tvSeasonFactory) | ||
{ | ||
$this->tvSeasonFactory = $tvSeasonFactory; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return \Tmdb\Factory\TvSeasonFactory | ||
*/ | ||
public function getTvSeasonFactory() | ||
{ | ||
return $this->tvSeasonFactory; | ||
} | ||
|
||
/** | ||
* @param \Tmdb\Factory\PeopleFactory $peopleFactory | ||
* @return $this | ||
*/ | ||
public function setPeopleFactory($peopleFactory) | ||
{ | ||
$this->peopleFactory = $peopleFactory; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return \Tmdb\Factory\PeopleFactory | ||
*/ | ||
public function getPeopleFactory() | ||
{ | ||
return $this->peopleFactory; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?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 | ||
*/ | ||
namespace Tmdb\Model; | ||
|
||
use Tmdb\Model\Common\GenericCollection; | ||
|
||
class Certification extends AbstractModel { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $country; | ||
|
||
/** | ||
* @var GenericCollection | ||
*/ | ||
private $certifications; | ||
|
||
public static $_properties = array( | ||
'country', | ||
); | ||
|
||
public function __construct() | ||
{ | ||
$this->certifications = new GenericCollection(); | ||
} | ||
|
||
/** | ||
* @param \Tmdb\Model\Common\GenericCollection $certifications | ||
* @return $this | ||
*/ | ||
public function setCertifications($certifications) | ||
{ | ||
$this->certifications = $certifications; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return \Tmdb\Model\Common\GenericCollection | ||
*/ | ||
public function getCertifications() | ||
{ | ||
return $this->certifications; | ||
} | ||
|
||
/** | ||
* @param string $country | ||
* @return $this | ||
*/ | ||
public function setCountry($country) | ||
{ | ||
$this->country = $country; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCountry() | ||
{ | ||
return $this->country; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?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 | ||
*/ | ||
namespace Tmdb\Model\Certification; | ||
|
||
use Tmdb\Model\AbstractModel; | ||
|
||
class CountryCertification extends AbstractModel { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $certification; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $meaning; | ||
|
||
/** | ||
* @var integer | ||
*/ | ||
private $order; | ||
|
||
public static $_properties = array( | ||
'certification', | ||
'meaning', | ||
'order', | ||
); | ||
|
||
/** | ||
* @param string $certification | ||
* @return $this | ||
*/ | ||
public function setCertification($certification) | ||
{ | ||
$this->certification = $certification; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCertification() | ||
{ | ||
return $this->certification; | ||
} | ||
|
||
/** | ||
* @param string $meaning | ||
* @return $this | ||
*/ | ||
public function setMeaning($meaning) | ||
{ | ||
$this->meaning = $meaning; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMeaning() | ||
{ | ||
return $this->meaning; | ||
} | ||
|
||
/** | ||
* @param int $order | ||
* @return $this | ||
*/ | ||
public function setOrder($order) | ||
{ | ||
$this->order = $order; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getOrder() | ||
{ | ||
return $this->order; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?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 | ||
*/ | ||
namespace Tmdb\Repository; | ||
|
||
use Tmdb\Factory\CertificationFactory; | ||
use Tmdb\Model\Collection as ApiCollection; | ||
|
||
class CertificationRepository extends AbstractRepository { | ||
|
||
/** | ||
* Get the list of supported certifications for movies. | ||
* | ||
* These can be used in conjunction with the certification_country and certification.lte parameters when using discover. | ||
* | ||
* @param $parameters | ||
* @param $headers | ||
* @return null|\Tmdb\Model\AbstractModel | ||
*/ | ||
public function getMovieList(array $parameters = array(), array $headers = array()) | ||
{ | ||
$data = $this->getApi()->getMovieList($this->parseQueryParameters($parameters), $headers); | ||
return $this->getFactory()->createCollection($data); | ||
} | ||
|
||
/** | ||
* Return the Collection API Class | ||
* | ||
* @return \Tmdb\Api\Certifications | ||
*/ | ||
public function getApi() | ||
{ | ||
return $this->getClient()->getCertificationsApi(); | ||
} | ||
|
||
/** | ||
* @return CertificationFactory | ||
*/ | ||
public function getFactory() | ||
{ | ||
return new CertificationFactory(); | ||
} | ||
} |