public static function fillVideo(Video $video) { $videoType = DAOFactory::getVideoTypeDAO()->findById($video->getType()); $videoTypeName = $videoType->getName() . 'Filler'; $filler = new $videoTypeName($video); $video = $filler->getVideoTO(); $video->setType($videoType->getName()); return $video; }
public function detect($url) { $host = parse_url($this->url, PHP_URL_HOST); $videoTypes = DAOFactory::getVideoTypeDAO()->findAll(); foreach ($videoTypes as $type) { if (stristr($host, $type->getName())) { $this->type = $type; $this->initializeService(); break; } } // what if video is not of recognizable type? // exception? }