Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function create(array $data = array())
 {
     if (!$data) {
         return null;
     }
     $tvEpisode = new Episode();
     if (array_key_exists('credits', $data)) {
         if (array_key_exists('cast', $data['credits'])) {
             $tvEpisode->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast'], new CastMember()));
         }
         if (array_key_exists('crew', $data['credits'])) {
             $tvEpisode->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew'], new CrewMember()));
         }
     }
     /** External ids */
     if (array_key_exists('external_ids', $data)) {
         $tvEpisode->setExternalIds($this->hydrate(new ExternalIds(), $data['external_ids']));
     }
     /** Images */
     if (array_key_exists('images', $data)) {
         $tvEpisode->setImages($this->getImageFactory()->createCollectionFromTvEpisode($data['images']));
     }
     if (array_key_exists('still_path', $data)) {
         $tvEpisode->setStillImage($this->getImageFactory()->createFromPath($data['still_path'], 'still_path'));
     }
     if (array_key_exists('videos', $data)) {
         $tvEpisode->setVideos($this->getVideoFactory()->createCollection($data['videos']));
     }
     if (array_key_exists('changes', $data)) {
         $tvEpisode->setChanges($this->getChangesFactory()->createCollection($data['changes']));
     }
     return $this->hydrate($tvEpisode, $data);
 }
Exemple #2
0
 /**
  * @test
  */
 public function shouldConstructTvEpisode()
 {
     $this->assertInstanceOf('Tmdb\\Model\\Tv\\Episode', $this->episode);
     $this->assertInstanceOf('\\DateTime', $this->episode->getAirDate());
     $this->assertInstanceOf('Tmdb\\Model\\Collection\\CreditsCollection', $this->episode->getCredits());
     $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());
 }
Exemple #3
0
 /**
  * @test
  */
 public function shouldBeAbleToOverrideDefaultCollections()
 {
     $episode = new Episode();
     $class = new \stdClass();
     $episode->setCredits($class);
     $this->assertInstanceOf('stdClass', $episode->getCredits());
 }