public function testIfArrayProcessedCorrectly() { $arrayString = "|D|A|C|B|"; $arraySortedNoEmpty = ArrayUtils::extractValues($arrayString, true, true); $arrayNotSortedNoEmpty = ArrayUtils::extractValues($arrayString, true, false); $arrayWithEmpty = ArrayUtils::extractValues($arrayString, false, false); $this->assertEquals(array('A', 'B', 'C', 'D'), $arraySortedNoEmpty); $this->assertEquals(array(1 => 'D', 2 => 'A', 3 => 'C', 4 => 'B'), $arrayNotSortedNoEmpty); $this->assertEquals(array('', 'D', 'A', 'C', 'B', ''), $arrayWithEmpty); }
/** * Constructor * * @param $data \SimpleXMLElement $data A simplexmlobject created from thetvdb.com's xml data for the tv show * * @return Serie */ public function __construct(\SimpleXMLElement $data) { $this->setId((int) $data->id); $this->setLanguage((string) $data->Language); $this->setName((string) $data->SeriesName); $this->setBanner((string) $data->banner); $this->setOverview((string) $data->Overview); $this->setFirstAired(new \DateTime((string) $data->FirstAired)); $this->setImdbId((string) $data->IMDB_ID); $this->setActors((array) ArrayUtils::extractValues((string) $data->Actors)); $this->setAirsDayOfWeek((string) $data->Airs_DayOfWeek); $this->setAirsTime((string) $data->Airs_Time); $this->setContentRating((string) $data->ContentRating); $this->setGenres((array) ArrayUtils::extractValues((string) $data->Genre)); $this->setNetwork((string) $data->Network); $this->setRating((string) $data->Rating); $this->setRatingCount((int) $data->RatingCount); $this->setRuntime((int) $data->Runtime); $this->setStatus((string) $data->Status); $this->setAdded(new \DateTime((string) $data->added)); $this->setAddedBy((int) $data->addedBy); $this->setFanArt((string) $data->fanart); $this->setLastUpdated(\DateTime::createFromFormat('U', (int) $data->lastupdated)); $this->setPoster((string) $data->poster); $this->setZap2ItId((string) $data->zap2it_id); }
/** * Constructor * * @param SimpleXMLElement $data Retrieved SimpleXMLElement * * @return Episode */ public function __construct(SimpleXMLElement $data) { $this->setId((int) $data->id); if (isset($data->Combined_episodenumber)) { $this->setNumber((int) $data->Combined_episodenumber); } else { $this->setNumber((int) $data->EpisodeNumber); } if (isset($data->Combined_season)) { $this->setSeason((int) $data->Combined_season); } else { $this->setSeason((int) $data->SeasonNumber); } $this->setDirectors((array) ArrayUtils::extractValues((string) $data->Director)); $this->setName((string) $data->EpisodeName); $this->setFirstAired((string) $data->FirstAired !== '' ? new \DateTime((string) $data->FirstAired) : null); $this->setGuestStars((array) ArrayUtils::extractValues((string) $data->GuestStars)); $this->setImdbId((string) $data->IMDB_ID); $this->setLanguage((string) $data->Language); $this->setOverview((string) $data->Overview); $this->setRating((string) $data->Rating); $this->setRatingCount((int) $data->RatingCount); $this->setLastUpdated(\DateTime::createFromFormat('U', (int) $data->lastupdated)); $this->setWriters((array) ArrayUtils::extractValues((string) $data->Writer)); $this->setThumbnail((string) $data->filename); $this->setSeasonId((int) $data->seasonid); $this->setSerieId((int) $data->seriesid); $this->setDvdChapter((int) $data->DVD_chapter); $this->setDvdDiscId((int) $data->DVD_discid); $this->setDvdEpisodeNumber((int) $data->DVD_episodenumber); $this->setDvdSeason((int) $data->DVD_season); $this->setProductionCode((int) $data->ProductionCode); $this->setAbsoluteNumber((int) $data->absolute_number); $this->setAirsAfterSeason((int) $data->airsafter_season); $this->setAirsBeforeEpisode((int) $data->airsbefore_episode); $this->setAirsBeforeSeason((int) $data->airsbefore_season); }