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.
Updated images with a new found format, and preparing to move any "qu…
…ery" type of down to the "Query" namespace as this seems more logical.
- Loading branch information
1 parent
6cf99a4
commit e249d56
Showing
3 changed files
with
189 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,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(); | ||
} |
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,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(); | ||
} |