Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,32 @@ matrix:
env: [SF_EVT_DISPATCHER_VERSION="2.8.*", SF_OPT_RESOLVER_VERSION="2.8.*"]
- php: 5.6
env: [SF_EVT_DISPATCHER_VERSION="3.1.*", SF_OPT_RESOLVER_VERSION="3.1.*"]
- php: 5.6
env: [SF_EVT_DISPATCHER_VERSION="3.2.*", SF_OPT_RESOLVER_VERSION="3.2.*"]
- php: 7.0
env: [SF_EVT_DISPATCHER_VERSION="2.7.*", SF_OPT_RESOLVER_VERSION="2.7.*"]
- php: 7.0
env: [SF_EVT_DISPATCHER_VERSION="2.8.*", SF_OPT_RESOLVER_VERSION="2.8.*"]
- php: 7.0
env: [SF_EVT_DISPATCHER_VERSION="3.1.*", SF_OPT_RESOLVER_VERSION="3.1.*"]
- php: 7.0
env: [SF_EVT_DISPATCHER_VERSION="3.2.*", SF_OPT_RESOLVER_VERSION="3.2.*"]
- php: 7.1
env: [SF_EVT_DISPATCHER_VERSION="2.7.*", SF_OPT_RESOLVER_VERSION="2.7.*"]
- php: 7.1
env: [SF_EVT_DISPATCHER_VERSION="2.8.*", SF_OPT_RESOLVER_VERSION="2.8.*"]
- php: 7.1
env: [SF_EVT_DISPATCHER_VERSION="3.1.*", SF_OPT_RESOLVER_VERSION="3.1.*"]
- php: 7.1
env: [SF_EVT_DISPATCHER_VERSION="3.2.*", SF_OPT_RESOLVER_VERSION="3.2.*"]
- php: hhvm
env: [SF_EVT_DISPATCHER_VERSION="2.7.*", SF_OPT_RESOLVER_VERSION="2.7.*"]
- php: hhvm
env: [SF_EVT_DISPATCHER_VERSION="2.8.*", SF_OPT_RESOLVER_VERSION="2.8.*"]
- php: hhvm
env: [SF_EVT_DISPATCHER_VERSION="3.1.*", SF_OPT_RESOLVER_VERSION="3.1.*"]
- php: hhvm
env: [SF_EVT_DISPATCHER_VERSION="3.2.*", SF_OPT_RESOLVER_VERSION="3.2.*"]
allow_failures:
- php: nightly
fast_finish: true
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"rtheunissen/guzzle-log-middleware": "^0.4.0"
},
"require-dev": {
"phpunit/phpunit": ">=5.7",
"phpunit/phpunit": ">=5.7,<6",
"monolog/monolog": ">=1.11.0"
},
"suggest": {
Expand Down
12 changes: 12 additions & 0 deletions lib/Tmdb/Factory/MovieFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ public function create(array $data = [])
$movie->setReleases($this->createGenericCollection($data['releases']['countries'], new Movie\Release()));
}

if (array_key_exists('release_dates', $data) && array_key_exists('results', $data['release_dates'])) {
$release_dates = new GenericCollection();
foreach ($data['release_dates']['results'] as $country_releases) {
$iso_31661 = $country_releases['iso_3166_1'];
foreach($country_releases['release_dates'] as $release_date) {
$release_date['iso_3166_1'] = $iso_31661;
$release_dates->add(null, $this->hydrate(new Movie\ReleaseDate(), $release_date));
}
}
$movie->setReleaseDates($release_dates);
}

if (array_key_exists('videos', $data)) {
$movie->setVideos($this->getVideoFactory()->createCollection($data['videos']));
}
Expand Down
36 changes: 33 additions & 3 deletions lib/Tmdb/Model/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use Tmdb\Model\Collection\ResultCollection;
use Tmdb\Model\Collection\Videos;
use Tmdb\Model\Common\Country;
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Collection\CreditsCollection;
use Tmdb\Model\Collection\Genres;
Expand All @@ -22,6 +23,7 @@
use Tmdb\Model\Common\Translation;
use Tmdb\Model\Movie\AlternativeTitle;
use Tmdb\Model\Movie\Release;
use Tmdb\Model\Movie\ReleaseDate;

/**
* Class Movie
Expand Down Expand Up @@ -195,9 +197,15 @@ class Movie extends AbstractModel

/**
* @var GenericCollection
* @deprecated Use $release_dates instead
*/
protected $releases;

/**
* @var GenericCollection
*/
protected $release_dates;

/**
* @var GenericCollection
*/
Expand Down Expand Up @@ -266,6 +274,7 @@ public function __construct()
$this->keywords = new GenericCollection();
$this->lists = new GenericCollection();
$this->releases = new GenericCollection();
$this->release_dates = new GenericCollection();
$this->similar = new GenericCollection();
$this->translations = new GenericCollection();
$this->videos = new Videos();
Expand Down Expand Up @@ -849,6 +858,7 @@ public function getLists()
/**
* @param GenericCollection $releases
* @return $this
* @deprecated Use the setReleaseDates instead.
*/
public function setReleases(GenericCollection $releases)
{
Expand All @@ -859,12 +869,32 @@ public function setReleases(GenericCollection $releases)

/**
* @return GenericCollection|Release[]
* @deprecated Use the getReleaseDates instead
*/
public function getReleases()
{
return $this->releases;
}

/**
* @param GenericCollection $release_dates
* @return $this
*/
public function setReleaseDates(GenericCollection $release_dates)
{
$this->release_dates = $release_dates;

return $this;
}

/**
* @return GenericCollection|ReleaseDate[]
*/
public function getReleaseDates()
{
return $this->release_dates;
}

/**
* @param GenericCollection $similar
* @return $this
Expand All @@ -877,16 +907,16 @@ public function setSimilar($similar)
}

/**
* @return Movie[]
* @return GenericCollection|Movie[]
*/
public function getSimilar()
{
return $this->similar;
}

/**
* @return Movie[]
* @deprecated
* @return GenericCollection|Movie[]
* @deprecated Use getSimilar instead
*/
public function getSimilarMovies()
{
Expand Down
5 changes: 5 additions & 0 deletions lib/Tmdb/Model/Movie/QueryParameter/AppendToResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ final class AppendToResponse extends BaseAppendToResponse
const CREDITS = 'credits';
const IMAGES = 'images';
const KEYWORDS = 'keywords';
/**
* @see https://developers.themoviedb.org/3/movies/get-movie-release-dates
* @deprecated Use RELEASE_DATES instead, but format has changed.
*/
const RELEASES = 'releases';
const RELEASE_DATES = 'release_dates';
const TRANSLATIONS = 'translations';
const SIMILAR = 'similar';
const REVIEWS = 'reviews';
Expand Down
1 change: 1 addition & 0 deletions lib/Tmdb/Model/Movie/Release.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
/**
* Class Release
* @package Tmdb\Model\Movie
* @deprecated Use ReleaseDate instead
*/
class Release extends AbstractModel implements CountryFilter
{
Expand Down
164 changes: 164 additions & 0 deletions lib/Tmdb/Model/Movie/ReleaseDate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<?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 <michael@wtfz.net>
* @copyright (c) 2013, Michael Roterman
* @version 2.1.7
*/
namespace Tmdb\Model\Movie;

use Tmdb\Model\AbstractModel;
use Tmdb\Model\Filter\CountryFilter;
use Tmdb\Model\Filter\LanguageFilter;

/**
* Class Release Date
* @package Tmdb\Model\Movie
*/
class ReleaseDate extends AbstractModel implements CountryFilter, LanguageFilter
{
const PREMIERE = 1;
const THEATRICAL_LIMITED = 2;
const THEATRICAL = 3;
const DIGITAL = 4;
const PHYSICAL = 5;
const TV = 6;

private $iso31661;
private $iso6391;
private $certification;
private $note;
private $releaseDate;
private $type;

public static $properties = [
'iso_3166_1',
'iso_639_1',
'certification',
'note',
'release_date',
'type'
];

/**
* @param string|null $certification
* @return $this
*/
public function setCertification($certification)
{
$this->certification = $certification;

return $this;
}

/**
* @return string|null
*/
public function getCertification()
{
return $this->certification;
}

/**
* @param string|null $note
* @return $this
*/
public function setNote($note)
{
$this->note = $note;

return $this;
}

/**
* @return string|null
*/
public function getNote()
{
return $this->note;
}

/**
* @param string $iso31661
* @return $this
*/
public function setIso31661($iso31661)
{
$this->iso31661 = $iso31661;

return $this;
}

/**
* @return string
*/
public function getIso31661()
{
return $this->iso31661;
}

/**
* @param string|\DateTime $releaseDate
* @return $this
*/
public function setReleaseDate($releaseDate)
{
if (!$releaseDate instanceof \DateTime) {
$releaseDate = new \DateTime($releaseDate);
}

$this->releaseDate = $releaseDate;

return $this;
}

/**
* @return \DateTime
*/
public function getReleaseDate()
{
return $this->releaseDate;
}

/**
* @param string $iso6391
* @return $this
*/
public function setIso6391($iso6391)
{
$this->iso6391 = $iso6391;
return $this;
}

/**
* @return string|null
*/
public function getIso6391()
{
return $this->iso6391;
}

/**
* @param int $type
* @return $this
*/
public function setType($type)
{
$this->type = $type;

return $this;
}

/**
* @return int
*/
public function getType()
{
return $this->type;
}
}
2 changes: 1 addition & 1 deletion lib/Tmdb/Repository/MovieRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function load($id, array $parameters = [], array $headers = [])
AppendToResponse::IMAGES,
AppendToResponse::KEYWORDS,
AppendToResponse::LISTS,
AppendToResponse::RELEASES,
AppendToResponse::RELEASE_DATES,
AppendToResponse::REVIEWS,
AppendToResponse::SIMILAR,
AppendToResponse::TRANSLATIONS,
Expand Down
13 changes: 13 additions & 0 deletions test/Tmdb/Tests/Factory/MovieFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

use Tmdb\Factory\MovieFactory;
use Tmdb\Model\Movie;
use Tmdb\Model\Movie\Release;
use Tmdb\Model\Movie\ReleaseDate;
use Tmdb\Model\Person\CastMember;

class MovieFactoryTest extends TestCase
Expand Down Expand Up @@ -103,12 +105,23 @@ public function shouldBeFunctional()
$this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->movie->getKeywords());
$this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->movie->getLists());
$this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->movie->getReleases());
$this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->movie->getReleaseDates());
$this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->movie->getSimilar());
$this->assertInstanceOf('Tmdb\Model\Collection\Videos', $this->movie->getVideos());

/** @var Release[] $releases */
$releases = $this->movie->getReleases()->getAll();
$primaryRelease = array_shift($releases);
$this->assertEquals(true, $primaryRelease->getPrimary());

/** @var ReleaseDate[] $release_dates */
$release_dates = $this->movie->getReleaseDates()->getAll();
$this->assertEquals(46, count($release_dates));
foreach($release_dates as $release_date) {
$this->assertNotEmpty($release_date->getIso31661());
$this->assertInstanceOf(\DateTime::class, $release_date->getReleaseDate());
$this->assertTrue(is_int($release_date->getType()));
}
}

/**
Expand Down
Loading