1<?php 2 3/** 4 * @see https://github.com/laminas/laminas-feed for the canonical source repository 5 * @copyright https://github.com/laminas/laminas-feed/blob/master/COPYRIGHT.md 6 * @license https://github.com/laminas/laminas-feed/blob/master/LICENSE.md New BSD License 7 */ 8 9namespace Laminas\Feed\Reader\Extension\Podcast; 10 11use Laminas\Feed\Reader\Extension; 12 13class Entry extends Extension\AbstractEntry 14{ 15 /** 16 * Get the entry author 17 * 18 * @return string 19 */ 20 public function getCastAuthor() 21 { 22 if (isset($this->data['author'])) { 23 return $this->data['author']; 24 } 25 26 $author = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:author)'); 27 28 if (! $author) { 29 $author = null; 30 } 31 32 $this->data['author'] = $author; 33 34 return $this->data['author']; 35 } 36 37 /** 38 * Get the entry block 39 * 40 * @return string 41 */ 42 public function getBlock() 43 { 44 if (isset($this->data['block'])) { 45 return $this->data['block']; 46 } 47 48 $block = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:block)'); 49 50 if (! $block) { 51 $block = null; 52 } 53 54 $this->data['block'] = $block; 55 56 return $this->data['block']; 57 } 58 59 /** 60 * Get the entry duration 61 * 62 * @return string 63 */ 64 public function getDuration() 65 { 66 if (isset($this->data['duration'])) { 67 return $this->data['duration']; 68 } 69 70 $duration = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:duration)'); 71 72 if (! $duration) { 73 $duration = null; 74 } 75 76 $this->data['duration'] = $duration; 77 78 return $this->data['duration']; 79 } 80 81 /** 82 * Get the entry explicit 83 * 84 * @return string 85 */ 86 public function getExplicit() 87 { 88 if (isset($this->data['explicit'])) { 89 return $this->data['explicit']; 90 } 91 92 $explicit = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:explicit)'); 93 94 if (! $explicit) { 95 $explicit = null; 96 } 97 98 $this->data['explicit'] = $explicit; 99 100 return $this->data['explicit']; 101 } 102 103 /** 104 * Get the entry keywords 105 * 106 * @deprecated since 2.10.0; itunes:keywords is no longer part of the 107 * iTunes podcast RSS specification. 108 * @return string 109 */ 110 public function getKeywords() 111 { 112 trigger_error( 113 'itunes:keywords has been deprecated in the iTunes podcast RSS specification,' 114 . ' and should not be relied on.', 115 \E_USER_DEPRECATED 116 ); 117 118 if (isset($this->data['keywords'])) { 119 return $this->data['keywords']; 120 } 121 122 $keywords = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:keywords)'); 123 124 if (! $keywords) { 125 $keywords = null; 126 } 127 128 $this->data['keywords'] = $keywords; 129 130 return $this->data['keywords']; 131 } 132 133 /** 134 * Get the entry title 135 * 136 * @return string 137 */ 138 public function getTitle() 139 { 140 if (isset($this->data['title'])) { 141 return $this->data['title']; 142 } 143 144 $title = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:title)'); 145 146 if (! $title) { 147 $title = null; 148 } 149 150 $this->data['title'] = $title; 151 152 return $this->data['title']; 153 } 154 155 /** 156 * Get the entry subtitle 157 * 158 * @return string 159 */ 160 public function getSubtitle() 161 { 162 if (isset($this->data['subtitle'])) { 163 return $this->data['subtitle']; 164 } 165 166 $subtitle = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:subtitle)'); 167 168 if (! $subtitle) { 169 $subtitle = null; 170 } 171 172 $this->data['subtitle'] = $subtitle; 173 174 return $this->data['subtitle']; 175 } 176 177 /** 178 * Get the entry summary 179 * 180 * @return string 181 */ 182 public function getSummary() 183 { 184 if (isset($this->data['summary'])) { 185 return $this->data['summary']; 186 } 187 188 $summary = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:summary)'); 189 190 if (! $summary) { 191 $summary = null; 192 } 193 194 $this->data['summary'] = $summary; 195 196 return $this->data['summary']; 197 } 198 199 /** 200 * Get the entry image 201 * 202 * @return string 203 */ 204 public function getItunesImage() 205 { 206 if (isset($this->data['image'])) { 207 return $this->data['image']; 208 } 209 210 $image = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:image/@href)'); 211 212 if (! $image) { 213 $image = null; 214 } 215 216 $this->data['image'] = $image; 217 218 return $this->data['image']; 219 } 220 221 /** 222 * Get the episode number 223 * 224 * @return null|int 225 */ 226 public function getEpisode() 227 { 228 if (isset($this->data['episode'])) { 229 return $this->data['episode']; 230 } 231 232 $episode = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:episode)'); 233 234 if (! $episode) { 235 $episode = null; 236 } 237 238 $this->data['episode'] = null === $episode ? $episode : (int) $episode; 239 240 return $this->data['episode']; 241 } 242 243 /** 244 * Get the episode number 245 * 246 * @return string One of "full", "trailer", or "bonus"; defaults to "full". 247 */ 248 public function getEpisodeType() 249 { 250 if (isset($this->data['episodeType'])) { 251 return $this->data['episodeType']; 252 } 253 254 $type = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:episodeType)'); 255 256 if (! $type) { 257 $type = 'full'; 258 } 259 260 $this->data['episodeType'] = (string) $type; 261 262 return $this->data['episodeType']; 263 } 264 265 /** 266 * Is the episode closed captioned? 267 * 268 * Returns true only if itunes:isClosedCaptioned has the value 'Yes'. 269 * 270 * @return bool 271 */ 272 public function isClosedCaptioned() 273 { 274 if (isset($this->data['isClosedCaptioned'])) { 275 return $this->data['isClosedCaptioned']; 276 } 277 278 $status = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:isClosedCaptioned)'); 279 280 $this->data['isClosedCaptioned'] = $status === 'Yes'; 281 282 return $this->data['isClosedCaptioned']; 283 } 284 285 /** 286 * Get the season number 287 * 288 * @return null|int 289 */ 290 public function getSeason() 291 { 292 if (isset($this->data['season'])) { 293 return $this->data['season']; 294 } 295 296 $season = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:season)'); 297 298 if (! $season) { 299 $season = null; 300 } 301 302 $this->data['season'] = null === $season ? $season : (int) $season; 303 304 return $this->data['season']; 305 } 306 307 /** 308 * Register iTunes namespace 309 */ 310 protected function registerNamespaces() 311 { 312 $this->xpath->registerNamespace('itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd'); 313 } 314} 315