Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class RssChannelWorker extends Singleton implements FeedChannelWorker
00016 {
00020 public static function me()
00021 {
00022 return Singleton::getInstance(__CLASS__);
00023 }
00024
00028 public function makeChannel(SimpleXMLElement $xmlFeed)
00029 {
00030 if (
00031 (!isset($xmlFeed->channel))
00032 || (!isset($xmlFeed->channel->title))
00033 )
00034 throw new WrongStateException(
00035 'there are no channels in given rss'
00036 );
00037
00038 $feedChannel =
00039 FeedChannel::create((string) $xmlFeed->channel->title);
00040
00041 if (isset($xmlFeed->channel->link))
00042 $feedChannel->setLink((string) $xmlFeed->channel->link);
00043
00044 return $feedChannel;
00045 }
00046
00047 public function toXml(FeedChannel $channel, $itemsXml)
00048 {
00049 return
00050 '<rss version="'.RssFeedFormat::VERSION.'">'
00051 .'<channel>'
00052 .'<title>'.$channel->getTitle().'</title>'
00053 .(
00054 $channel->getLink()
00055 ? '<link>'.$channel->getLink().'</link>'
00056 : null
00057 )
00058 .(
00059 $channel->getDescription()
00060 ?
00061 '<description>'
00062 .$channel->getDescription()
00063 .'</description>'
00064 : null
00065 )
00066 .$itemsXml
00067 .'</channel>'
00068 .'</rss>';
00069 }
00070 }
00071 ?>