Skip to content

Commit

Permalink
Updated images with a new found format, and preparing to move any "qu…
Browse files Browse the repository at this point in the history
…ery" type of down to the "Query" namespace as this seems more logical.
  • Loading branch information
wtfzdotnet committed Nov 2, 2013
1 parent 6cf99a4 commit e249d56
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Tmdb/Model/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Image extends AbstractModel {
const FORMAT_BACKDROP = 'backdrop';
const FORMAT_PROFILE = 'profile';
const FORMAT_LOGO = 'logo';
const FORMAT_STILL = 'still';

private $filePath;
private $width;
Expand All @@ -42,7 +43,8 @@ class Image extends AbstractModel {
'posters' => self::FORMAT_POSTER,
'backdrops' => self::FORMAT_BACKDROP,
'profiles' => self::FORMAT_PROFILE,
'logos' => self::FORMAT_LOGO
'logos' => self::FORMAT_LOGO,
'stills' => self::FORMAT_STILL
);

/**
Expand Down
93 changes: 93 additions & 0 deletions lib/Tmdb/Model/Query/Changes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?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\Client;
use Tmdb\Model\Changes\Change;
use Tmdb\Model\Common\Collection;

class Changes extends AbstractModel {

private $from = null;
private $to = null;
private $page = null;

public function __construct(Client $client)
{
$this->setClient($client);
}

/**
* Set the from parameter
*
* @param \DateTime $date
* @return $this
*/
public function from(\DateTime $date)
{
$this->from = $date->format('Y-m-d');

return $this;
}

/**
* Set the to parameter
*
* @param \DateTime $date
* @return $this
*/
public function to(\DateTime $date)
{
$this->to = $date->format('Y-m-d');

return $this;
}

/**
* Set the page parameter
*
* @param int $page
* @return $this
*/
public function page($page = 1) {
$this->page = (int) $page;

return $this;
}

/**
* Execute the current state
*
* @return Collection
*/
public function execute()
{
$collection = new Collection();

$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(null, Change::fromArray($this->getClient(), $change));
}
}

return $collection;
}

//abstract public function getEntity();
}
93 changes: 93 additions & 0 deletions lib/Tmdb/Model/Query/Discover.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?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\Query;

use Tmdb\Client;
use Tmdb\Model\Changes\Change;
use Tmdb\Model\Common\Collection;

class Discover extends AbstractModel {

private $from = null;
private $to = null;
private $page = null;

public function __construct(Client $client)
{
$this->setClient($client);
}

/**
* Set the from parameter
*
* @param \DateTime $date
* @return $this
*/
public function from(\DateTime $date)
{
$this->from = $date->format('Y-m-d');

return $this;
}

/**
* Set the to parameter
*
* @param \DateTime $date
* @return $this
*/
public function to(\DateTime $date)
{
$this->to = $date->format('Y-m-d');

return $this;
}

/**
* Set the page parameter
*
* @param int $page
* @return $this
*/
public function page($page = 1) {
$this->page = (int) $page;

return $this;
}

/**
* Execute the current state
*
* @return Collection
*/
public function execute()
{
$collection = new Collection();

$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(null, Change::fromArray($this->getClient(), $change));
}
}

return $collection;
}

//abstract public function getEntity();
}

0 comments on commit e249d56

Please sign in to comment.