Skip to content

Commit

Permalink
Removing unnecassary classes related to people
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 5, 2014
1 parent e9254ff commit 19003d5
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 133 deletions.
4 changes: 2 additions & 2 deletions lib/Tmdb/Factory/TvEpisodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use Tmdb\Factory\People\CastFactory;
use Tmdb\Factory\People\CrewFactory;
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Person\CastMember;
use Tmdb\Model\Person\CrewMember;
use Tmdb\Model\Tv\ExternalIds;
use Tmdb\Model\Tv\Person\CastMember;
use Tmdb\Model\Tv\Person\CrewMember;
use Tmdb\Model\Tv\Episode;

class TvEpisodeFactory extends AbstractFactory {
Expand Down
6 changes: 4 additions & 2 deletions lib/Tmdb/Factory/TvFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Tmdb\Factory\People\CrewFactory;
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Common\Translation;
use Tmdb\Model\Person\CastMember;
use Tmdb\Model\Person\CrewMember;
use Tmdb\Model\Tv\ExternalIds;
use Tmdb\Model\Tv;

Expand Down Expand Up @@ -70,11 +72,11 @@ public function create(array $data = array())

if (array_key_exists('credits', $data)) {
if (array_key_exists('cast', $data['credits'])) {
$tvShow->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast'], new Tv\Person\CastMember()));
$tvShow->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast'], new CastMember()));
}

if (array_key_exists('crew', $data['credits'])) {
$tvShow->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew'], new Tv\Person\CrewMember()));
$tvShow->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew'], new CrewMember()));
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Tmdb/Factory/TvSeasonFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use Tmdb\Factory\People\CastFactory;
use Tmdb\Factory\People\CrewFactory;
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Person\CastMember;
use Tmdb\Model\Person\CrewMember;
use Tmdb\Model\Tv\ExternalIds;
use Tmdb\Model\Tv\Person\CastMember;
use Tmdb\Model\Tv\Person\CrewMember;
use Tmdb\Model\Tv\Season;

class TvSeasonFactory extends AbstractFactory {
Expand Down
39 changes: 15 additions & 24 deletions lib/Tmdb/Model/Person/AbstractMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,29 @@

abstract class AbstractMember extends AbstractModel {

/**
* @var int
*/
private $id;

/**
* @var string
*/
private $name;

/**
* @var string
*/
private $profilePath;
private $order;

/**
* @var Image
* @var Image\ProfileImage
*/
private $profile;

public static $_properties = array(
'id',
'name',
'order',
'profile_path'
);

Expand Down Expand Up @@ -89,35 +98,17 @@ public function getProfilePath()
}

/**
* @param integer $order
* @return $this
*/
public function setOrder($order)
{
$this->order = $order;
return $this;
}

/**
* @return integer
*/
public function getOrder()
{
return $this->order;
}

/**
* @param Image $profile
* @param Image\ProfileImage $profile
* @return $this
*/
public function setProfile(Image $profile)
public function setProfile($profile = null)
{
$this->profile = $profile;
return $this;
}

/**
* @return Image
* @return Image\ProfileImage|null
*/
public function getProfile()
{
Expand Down
11 changes: 11 additions & 0 deletions lib/Tmdb/Model/Person/CastMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@

class CastMember extends AbstractMember implements PersonInterface {

/**
* @var string
*/
private $character;

/**
* @var int
*/
private $order;

/**
* @var mixed
*/
private $castId;

public static $_properties = array(
Expand Down
7 changes: 7 additions & 0 deletions lib/Tmdb/Model/Person/CrewMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@

class CrewMember extends AbstractMember implements PersonInterface {

/**
* @var string
*/
private $department;

/**
* @var string
*/
private $job;

public static $_properties = array(
Expand Down
85 changes: 0 additions & 85 deletions lib/Tmdb/Model/Tv/Person/CastMember.php

This file was deleted.

18 changes: 0 additions & 18 deletions lib/Tmdb/Model/Tv/Person/CrewMember.php

This file was deleted.

46 changes: 46 additions & 0 deletions test/Tmdb/Tests/Model/Person/CastMemberTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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\Tests\Model\Person;

use Tmdb\Common\ObjectHydrator;
use Tmdb\Model\Person\CastMember;
use Tmdb\Tests\Model\TestCase;

class CastMemberTest extends TestCase
{
/**
* @test
*/
public function shouldBeFunctional()
{
$data = array(
'id' => 819,
'name' => 'Edward Norton',
'character' => 'The Narrator',
'order' => 0,
'cast_id' => 4,
'profile_path' => '/588Hrov6wwM9WcU88nJHlw2iufN.jpg'
);

$hydrator = new ObjectHydrator();

$object = $hydrator->hydrate(new CastMember(), $data);

$this->assertEquals(819, $object->getId());
$this->assertEquals('Edward Norton', $object->getName());
$this->assertEquals('The Narrator', $object->getCharacter());
$this->assertEquals(0, $object->getOrder());
$this->assertEquals(4, $object->getCastId());
$this->assertEquals('/588Hrov6wwM9WcU88nJHlw2iufN.jpg', $object->getProfilePath());
}
}
44 changes: 44 additions & 0 deletions test/Tmdb/Tests/Model/Person/CrewMemberTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?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\Tests\Model\Person;

use Tmdb\Common\ObjectHydrator;
use Tmdb\Model\Person\CrewMember;
use Tmdb\Tests\Model\TestCase;

class CrewMemberTest extends TestCase
{
/**
* @test
*/
public function shouldBeFunctional()
{
$data = array(
'id' => 7477,
'name' => 'John King',
'department' => 'Sound',
'job' => 'Original Music Composer',
'profile_path' => null
);

$hydrator = new ObjectHydrator();

$object = $hydrator->hydrate(new CrewMember(), $data);

$this->assertEquals(7477, $object->getId());
$this->assertEquals('John King', $object->getName());
$this->assertEquals('Sound', $object->getDepartment());
$this->assertEquals('Original Music Composer', $object->getJob());
$this->assertEquals(null, $object->getProfilePath());
}
}
46 changes: 46 additions & 0 deletions test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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\Tests\Model\Tv;

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

class ExternalIdsTest extends TestCase
{
/**
* @test
*/
public function shouldBeFunctional()
{
$data = array(
'imdb_id' => 'tt0903747',
'freebase_id' => '/en/breaking_bad',
'freebase_mid' => '/m/03d34x8',
'id' => 1396,
'tvdb_id' => 81189,
'tvrage_id' => 18164,
);

$hydrator = new ObjectHydrator();

$object = $hydrator->hydrate(new ExternalIds(), $data);

$this->assertEquals('tt0903747', $object->getImdbId());
$this->assertEquals('/en/breaking_bad', $object->getFreebaseId());
$this->assertEquals('/m/03d34x8', $object->getFreebaseMid());
$this->assertEquals(1396, $object->getId());
$this->assertEquals(81189, $object->getTvdbId());
$this->assertEquals(18164, $object->getTvrageId());
}
}
Loading

0 comments on commit 19003d5

Please sign in to comment.