Skip to content

Commit

Permalink
Implementing ReviewRepository and adding example.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 8, 2014
1 parent 7eb94e6 commit f50bf6f
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/reviews/model/get.php
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);


$repository = new \Tmdb\Repository\ReviewRepository($client);
$review = $repository->load('5013bc76760ee372cb00253e');

var_dump($review);
50 changes: 50 additions & 0 deletions lib/Tmdb/Repository/ReviewRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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\ReviewFactory;
use Tmdb\Model\Review;

class ReviewRepository extends AbstractRepository {
/**
* Get the full details of a review by ID.
*
* @param $id
* @param array $parameters
* @param array $headers
* @return Review
*/
public function load($id, array $parameters = array(), array $headers = array()) {
return $this->getFactory()->create(
$this->getApi()->getReview($id, $parameters, $headers)
);
}

/**
* Return the related API class
*
* @return \Tmdb\Api\Reviews
*/
public function getApi()
{
return $this->getClient()->getReviewsApi();
}

/**
* @return ReviewFactory
*/
public function getFactory()
{
return new ReviewFactory();
}
}

0 comments on commit f50bf6f

Please sign in to comment.