/** * @expectedException Exception */ public function testGetGetMethodException() { $object = new \stdClass(); Utils::getGetMethod($object, 'unknown'); }
/** * decorate w/ the video element before the closing tag * * @return string */ public function toXml() { $videoXml = '<video:video>'; //---------------------- // required fields $videoXml .= '<video:thumbnail_loc>' . Utils::encode($this->getThumbnailLoc()) . '</video:thumbnail_loc>'; foreach (array('title', 'description') as $paramName) { $videoXml .= '<video:' . $paramName . '>' . Utils::render($this->{Utils::getGetMethod($this, $paramName)}()) . '</video:' . $paramName . '>'; } //---------------------- //---------------------- // simple optionnal fields if ($this->getCategory()) { $videoXml .= '<video:category>' . Utils::render($this->getCategory()) . '</video:category>'; } if ($this->getContentLoc()) { $videoXml .= '<video:content_loc>' . Utils::encode($this->getContentLoc()) . '</video:content_loc>'; } foreach (array('duration', 'rating', 'view_count', 'family_friendly', 'requires_subscription', 'live') as $paramName) { $getMethod = Utils::getGetMethod($this, $paramName); if ($this->{$getMethod}()) { $videoXml .= '<video:' . $paramName . '>' . $this->{$getMethod}() . '</video:' . $paramName . '>'; } } //---------------------- //---------------------- // date based optionnal fields foreach (array('expiration_date', 'publication_date') as $paramName) { $getMethod = Utils::getGetMethod($this, $paramName); if ($this->{$getMethod}()) { $videoXml .= '<video:' . $paramName . '>' . $this->{$getMethod}()->format('c') . '</video:' . $paramName . '>'; } } //---------------------- //---------------------- // moar complexe optionnal fields if ($this->getPlayerLoc()) { $allow_embed = $this->getPlayerLocAllowEmbed() ? ' allow_embed="' . $this->getPlayerLocAllowEmbed() . '"' : ''; $autoplay = $this->getPlayerLocAutoplay() ? ' autoplay="' . $this->getPlayerLocAutoplay() . '"' : ''; $videoXml .= '<video:player_loc' . $allow_embed . $autoplay . '>' . Utils::encode($this->getPlayerLoc()) . '</video:player_loc>'; } if ($this->getRestrictionAllow()) { $videoXml .= '<video:restriction relationship="allow">' . implode(' ', $this->getRestrictionAllow()) . '</video:restriction>'; } if ($this->getRestrictionDeny()) { $videoXml .= '<video:restriction relationship="deny">' . implode(' ', $this->getRestrictionDeny()) . '</video:restriction>'; } if ($this->getGalleryLoc()) { $title = $this->getGalleryLocTitle() ? ' title="' . Utils::encode($this->getGalleryLocTitle()) . '"' : ''; $videoXml .= '<video:gallery_loc' . $title . '>' . Utils::encode($this->getGalleryLoc()) . '</video:gallery_loc>'; } foreach ($this->getTags() as $tag) { $videoXml .= '<video:tag>' . Utils::render($tag) . '</video:tag>'; } foreach ($this->getPrices() as $price) { $type = $price['type'] ? ' type="' . $price['type'] . '"' : ''; $resolution = $price['resolution'] ? ' resolution="' . $price['resolution'] . '"' : ''; $videoXml .= '<video:price currency="' . $price['currency'] . '"' . $type . $resolution . '>' . $price['amount'] . '</video:price>'; } if ($this->getUploader()) { $info = $this->getUploaderInfo() ? ' info="' . $this->getUploaderInfo() . '"' : ''; $videoXml .= '<video:uploader' . $info . '>' . $this->getUploader() . '</video:uploader>'; } if (count($this->getPlatforms())) { $relationship = $this->getPlatformRelationship(); $videoXml .= '<video:platform relationship="' . $relationship . '">' . implode(' ', $this->getPlatforms()) . '</video:platform>'; } //---------------------- $videoXml .= '</video:video>'; $baseXml = $this->urlDecorated->toXml(); return str_replace('</url>', $videoXml . '</url>', $baseXml); }