From 6cf99a46590c59ee8a1ab573f4037f93c929f26f Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sat, 2 Nov 2013 03:20:56 +0100 Subject: [PATCH] Patched up changes --- lib/Tmdb/Api/Changes.php | 4 +-- lib/Tmdb/Model/Changes.php | 22 ++++++++++----- lib/Tmdb/Model/Changes/Change.php | 45 +++++++++++-------------------- 3 files changed, 34 insertions(+), 37 deletions(-) diff --git a/lib/Tmdb/Api/Changes.php b/lib/Tmdb/Api/Changes.php index 816c6059..f34ce1aa 100644 --- a/lib/Tmdb/Api/Changes.php +++ b/lib/Tmdb/Api/Changes.php @@ -31,7 +31,7 @@ class Changes */ public function getMovieChanges(array $options = array()) { - return $this->get('movie/changes/', $options); + return $this->get('movie/changes', $options); } /** @@ -50,6 +50,6 @@ public function getMovieChanges(array $options = array()) */ public function getPeopleChanges(array $options = array()) { - return $this->get('person/changes/', $options); + return $this->get('person/changes', $options); } } \ No newline at end of file diff --git a/lib/Tmdb/Model/Changes.php b/lib/Tmdb/Model/Changes.php index 63d7fd30..3b622606 100644 --- a/lib/Tmdb/Model/Changes.php +++ b/lib/Tmdb/Model/Changes.php @@ -13,9 +13,10 @@ namespace Tmdb\Model; use Tmdb\Client; +use Tmdb\Model\Changes\Change; use Tmdb\Model\Common\Collection; -abstract class Changes extends AbstractModel { +class Changes extends AbstractModel { private $from = null; private $to = null; @@ -32,7 +33,7 @@ public function __construct(Client $client) * @param \DateTime $date * @return $this */ - public function from($date) + public function from(\DateTime $date) { $this->from = $date->format('Y-m-d'); @@ -45,7 +46,7 @@ public function from($date) * @param \DateTime $date * @return $this */ - public function to($date) + public function to(\DateTime $date) { $this->to = $date->format('Y-m-d'); @@ -64,20 +65,29 @@ public function page($page = 1) { return $this; } + /** + * Execute the current state + * + * @return Collection + */ public function execute() { $collection = new Collection(); - $response = $this->getClient()->api('changes')->getMovieChanges(); + $response = $this->getClient()->api('changes')->getMovieChanges(array( + 'from' => $this->from, + 'to' => $this->to, + 'page' => $this->page + )); if (!empty($response)) { foreach($response['results'] as $change) { - $collection->add($change); + $collection->add(null, Change::fromArray($this->getClient(), $change)); } } return $collection; } - abstract public function getEntity(); + //abstract public function getEntity(); } \ No newline at end of file diff --git a/lib/Tmdb/Model/Changes/Change.php b/lib/Tmdb/Model/Changes/Change.php index 4c11fd26..39f70779 100644 --- a/lib/Tmdb/Model/Changes/Change.php +++ b/lib/Tmdb/Model/Changes/Change.php @@ -10,18 +10,19 @@ * @copyright (c) 2013, Michael Roterman * @version 0.0.1 */ -namespace Tmdb\Model; +namespace Tmdb\Model\Changes; use Tmdb\Client; +use Tmdb\Model\AbstractModel; class Change extends AbstractModel { private $id; - private $name; + private $adult = false; protected static $_properties = array( 'id', - 'name', + 'adult', ); /** @@ -33,60 +34,46 @@ class Change extends AbstractModel { */ public static function fromArray(Client $client, array $data) { - $genre = new Genre($data['id']); + $genre = new Change($data['id']); //$genre->setClient($client); return $genre->hydrate($data); } /** - * Load a person with the given identifier - * - * @param Client $client - * @param $id - * @param $options - * @return $this - */ - public static function load(Client $client, $id, array $options = array()) { - $data = $client->api('genres')->getGenre($id, $options); - - return Genre::fromArray($client, $data); - } - - /** - * @param mixed $id + * @param boolean $adult * @return $this */ - public function setId($id) + public function setAdult($adult) { - $this->id = (int) $id; + $this->adult = $adult; return $this; } /** - * @return mixed + * @return boolean */ - public function getId() + public function getAdult() { - return $this->id; + return $this->adult; } /** - * @param mixed $name + * @param mixed $id * @return $this */ - public function setName($name) + public function setId($id) { - $this->name = $name; + $this->id = $id; return $this; } /** * @return mixed */ - public function getName() + public function getId() { - return $this->name; + return $this->id; }