Skip to content

Commit

Permalink
Patched up changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Nov 2, 2013
1 parent 1700035 commit 6cf99a4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 37 deletions.
4 changes: 2 additions & 2 deletions lib/Tmdb/Api/Changes.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Changes
*/
public function getMovieChanges(array $options = array())
{
return $this->get('movie/changes/', $options);
return $this->get('movie/changes', $options);
}

/**
Expand All @@ -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);
}
}
22 changes: 16 additions & 6 deletions lib/Tmdb/Model/Changes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');

Expand All @@ -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');

Expand All @@ -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();
}
45 changes: 16 additions & 29 deletions lib/Tmdb/Model/Changes/Change.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);

/**
Expand All @@ -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;
}


Expand Down

0 comments on commit 6cf99a4

Please sign in to comment.