Skip to content

Commit

Permalink
Moving Tv\ExternalIds to Common\ExternalIds and implemented it in Person
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 8, 2014
1 parent 38ce990 commit 2305692
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 15 deletions.
8 changes: 8 additions & 0 deletions lib/Tmdb/Factory/PeopleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Tmdb\Model\Collection\People\Cast;
use Tmdb\Model\Collection\People\Crew;
use Tmdb\Model\Collection\People;
use Tmdb\Model\Common\ExternalIds;
use Tmdb\Model\Person\CastMember;
use Tmdb\Model\Person\CrewMember;
use Tmdb\Model\Person;
Expand Down Expand Up @@ -78,6 +79,13 @@ public function create(array $data = array(), Person\AbstractMember $person = nu
$person->setChanges($this->getChangeFactory()->createCollection($data['changes']));
}

/** External ids */
if (array_key_exists('external_ids', $data)) {
$person->setExternalIds(
$this->hydrate(new ExternalIds(), $data['external_ids'])
);
}

return $this->hydrate($person, $data);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Tmdb/Factory/TvEpisodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Person\CastMember;
use Tmdb\Model\Person\CrewMember;
use Tmdb\Model\Tv\ExternalIds;
use Tmdb\Model\Common\ExternalIds;
use Tmdb\Model\Tv\Episode;

class TvEpisodeFactory extends AbstractFactory {
Expand Down
2 changes: 1 addition & 1 deletion lib/Tmdb/Factory/TvFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Tmdb\Model\Common\Translation;
use Tmdb\Model\Person\CastMember;
use Tmdb\Model\Person\CrewMember;
use Tmdb\Model\Tv\ExternalIds;
use Tmdb\Model\Common\ExternalIds;
use Tmdb\Model\Tv;

class TvFactory extends AbstractFactory {
Expand Down
2 changes: 1 addition & 1 deletion lib/Tmdb/Factory/TvSeasonFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Person\CastMember;
use Tmdb\Model\Person\CrewMember;
use Tmdb\Model\Tv\ExternalIds;
use Tmdb\Model\Common\ExternalIds;
use Tmdb\Model\Tv\Season;

class TvSeasonFactory extends AbstractFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
namespace Tmdb\Model\Tv;
namespace Tmdb\Model\Common;

use Tmdb\Model\AbstractModel;

Expand Down
27 changes: 27 additions & 0 deletions lib/Tmdb/Model/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Tmdb\Model;

use Tmdb\Model\Collection\Credits;
use Tmdb\Model\Common\ExternalIds;
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Collection\Images;
use Tmdb\Model\Collection\People\PersonInterface;
Expand Down Expand Up @@ -105,6 +106,13 @@ class Person extends AbstractModel implements PersonInterface {
*/
protected $changes;

/**
* External Ids
*
* @var ExternalIds
*/
protected $externalIds;

public static $_properties = array(
'adult',
'also_known_as',
Expand All @@ -131,6 +139,7 @@ public function __construct()
$this->combinedCredits = new Credits\CombinedCredits();
$this->images = new Images();
$this->changes = new GenericCollection();
$this->externalIds = new ExternalIds();
}

/**
Expand Down Expand Up @@ -450,4 +459,22 @@ public function getTvCredits()
{
return $this->tvCredits;
}

/**
* @param \Tmdb\Model\Common\ExternalIds $externalIds
* @return $this
*/
public function setExternalIds($externalIds)
{
$this->externalIds = $externalIds;
return $this;
}

/**
* @return \Tmdb\Model\Common\ExternalIds
*/
public function getExternalIds()
{
return $this->externalIds;
}
}
6 changes: 3 additions & 3 deletions lib/Tmdb/Model/Tv.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Tmdb\Model\Collection\Images;
use Tmdb\Model\Image\BackdropImage;
use Tmdb\Model\Image\PosterImage;
use Tmdb\Model\Tv\ExternalIds;
use Tmdb\Model\Common\ExternalIds;
use Tmdb\Model\Tv\Network;

class Tv extends AbstractModel {
Expand Down Expand Up @@ -688,7 +688,7 @@ public function getImages()
}

/**
* @param \Tmdb\Model\Tv\ExternalIds $externalIds
* @param \Tmdb\Model\Common\ExternalIds $externalIds
* @return $this
*/
public function setExternalIds($externalIds)
Expand All @@ -698,7 +698,7 @@ public function setExternalIds($externalIds)
}

/**
* @return \Tmdb\Model\Tv\ExternalIds
* @return \Tmdb\Model\Common\ExternalIds
*/
public function getExternalIds()
{
Expand Down
1 change: 1 addition & 0 deletions lib/Tmdb/Model/Tv/Episode.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Tmdb\Model\AbstractModel;
use Tmdb\Model\Collection\Credits;
use Tmdb\Model\Collection\Images;
use Tmdb\Model\Common\ExternalIds;
use Tmdb\Model\Image\StillImage;

class Episode extends AbstractModel {
Expand Down
5 changes: 3 additions & 2 deletions lib/Tmdb/Model/Tv/Season.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Tmdb\Model\AbstractModel;
use Tmdb\Model\Collection\Credits;
use Tmdb\Model\Collection\Images;
use Tmdb\Model\Common\ExternalIds;
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Image\PosterImage;

Expand Down Expand Up @@ -253,7 +254,7 @@ public function getCredits()
}

/**
* @param \Tmdb\Model\Tv\ExternalIds $externalIds
* @param \Tmdb\Model\Common\ExternalIds $externalIds
* @return $this
*/
public function setExternalIds($externalIds)
Expand All @@ -263,7 +264,7 @@ public function setExternalIds($externalIds)
}

/**
* @return \Tmdb\Model\Tv\ExternalIds
* @return \Tmdb\Model\Common\ExternalIds
*/
public function getExternalIds()
{
Expand Down
2 changes: 1 addition & 1 deletion test/Tmdb/Tests/Factory/TvEpisodeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function shouldConstructTvEpisode()
$this->assertInstanceOf('\DateTime', $this->episode->getAirDate());

$this->assertInstanceOf('Tmdb\Model\Collection\Credits', $this->episode->getCredits());
$this->assertInstanceOf('Tmdb\Model\Tv\ExternalIds', $this->episode->getExternalIds());
$this->assertInstanceOf('Tmdb\Model\Common\ExternalIds', $this->episode->getExternalIds());
$this->assertInstanceOf('Tmdb\Model\Collection\Images', $this->episode->getImages());
$this->assertInstanceOf('Tmdb\Model\Image\StillImage', $this->episode->getStillImage());
}
Expand Down
2 changes: 1 addition & 1 deletion test/Tmdb/Tests/Factory/TvSeasonFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function shouldConstructTvSeason()
$this->assertInstanceOf('\DateTime', $this->season->getAirDate());

$this->assertInstanceOf('Tmdb\Model\Collection\Credits', $this->season->getCredits());
$this->assertInstanceOf('Tmdb\Model\Tv\ExternalIds', $this->season->getExternalIds());
$this->assertInstanceOf('Tmdb\Model\Common\ExternalIds', $this->season->getExternalIds());
$this->assertInstanceOf('Tmdb\Model\Collection\Images', $this->season->getImages());
$this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->season->getEpisodes());
$this->assertInstanceOf('Tmdb\Model\Image\PosterImage', $this->season->getPosterImage());
Expand Down
2 changes: 1 addition & 1 deletion test/Tmdb/Tests/Model/Tv/EpisodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function shouldConstructTvEpisode()
$episode,
array(
'getCredits' => 'Tmdb\Model\Collection\Credits',
'getExternalIds' => 'Tmdb\Model\Tv\ExternalIds',
'getExternalIds' => 'Tmdb\Model\Common\ExternalIds',
'getImages' => 'Tmdb\Model\Collection\Images',
)
);
Expand Down
2 changes: 1 addition & 1 deletion test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace Tmdb\Tests\Model\Tv;

use Tmdb\Common\ObjectHydrator;
use Tmdb\Model\Tv\ExternalIds;
use Tmdb\Model\Common\ExternalIds;
use Tmdb\Tests\Model\TestCase;

class ExternalIdsTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion test/Tmdb/Tests/Model/Tv/SeasonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function shouldConstructTvSeason()
$season,
array(
'getCredits' => 'Tmdb\Model\Collection\Credits',
'getExternalIds' => 'Tmdb\Model\Tv\ExternalIds',
'getExternalIds' => 'Tmdb\Model\Common\ExternalIds',
'getImages' => 'Tmdb\Model\Collection\Images',
'getEpisodes' => 'Tmdb\Model\Common\GenericCollection',
)
Expand Down
2 changes: 1 addition & 1 deletion test/Tmdb/Tests/Model/TvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function shouldConstructMovie()
'getOriginCountry' => 'Tmdb\Model\Common\GenericCollection',
'getSeasons' => 'Tmdb\Model\Common\GenericCollection',
'getCredits' => 'Tmdb\Model\Collection\Credits',
'getExternalIds' => 'Tmdb\Model\Tv\ExternalIds',
'getExternalIds' => 'Tmdb\Model\Common\ExternalIds',
'getImages' => 'Tmdb\Model\Collection\Images',
'getTranslations' => 'Tmdb\Model\Common\GenericCollection',
)
Expand Down

0 comments on commit 2305692

Please sign in to comment.