composer package updates
[openemr.git] / vendor / zendframework / zend-feed / src / Reader / Extension / Podcast / Feed.php
blob987fc6927163353bb8c90e0da039b1f6033eea23
1 <?php
2 /**
3 * @see https://github.com/zendframework/zend-feed for the canonical source repository
4 * @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com)
5 * @license https://github.com/zendframework/zend-feed/blob/master/LICENSE.md New BSD License
6 */
8 namespace Zend\Feed\Reader\Extension\Podcast;
10 use DOMText;
11 use Zend\Feed\Reader\Extension;
13 class Feed extends Extension\AbstractFeed
15 /**
16 * Get the entry author
18 * @return string
20 public function getCastAuthor()
22 if (isset($this->data['author'])) {
23 return $this->data['author'];
26 $author = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:author)');
28 if (! $author) {
29 $author = null;
32 $this->data['author'] = $author;
34 return $this->data['author'];
37 /**
38 * Get the entry block
40 * @return string
42 public function getBlock()
44 if (isset($this->data['block'])) {
45 return $this->data['block'];
48 $block = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:block)');
50 if (! $block) {
51 $block = null;
54 $this->data['block'] = $block;
56 return $this->data['block'];
59 /**
60 * Get the entry category
62 * @return array|null
64 public function getItunesCategories()
66 if (isset($this->data['categories'])) {
67 return $this->data['categories'];
70 $categoryList = $this->xpath->query($this->getXpathPrefix() . '/itunes:category');
72 $categories = [];
74 if ($categoryList->length > 0) {
75 foreach ($categoryList as $node) {
76 $children = null;
78 if ($node->childNodes->length > 0) {
79 $children = [];
81 foreach ($node->childNodes as $childNode) {
82 if (! ($childNode instanceof DOMText)) {
83 $children[$childNode->getAttribute('text')] = null;
88 $categories[$node->getAttribute('text')] = $children;
92 if (! $categories) {
93 $categories = null;
96 $this->data['categories'] = $categories;
98 return $this->data['categories'];
102 * Get the entry explicit
104 * @return string
106 public function getExplicit()
108 if (isset($this->data['explicit'])) {
109 return $this->data['explicit'];
112 $explicit = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:explicit)');
114 if (! $explicit) {
115 $explicit = null;
118 $this->data['explicit'] = $explicit;
120 return $this->data['explicit'];
124 * Get the feed/podcast image
126 * @return string
128 public function getItunesImage()
130 if (isset($this->data['image'])) {
131 return $this->data['image'];
134 $image = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:image/@href)');
136 if (! $image) {
137 $image = null;
140 $this->data['image'] = $image;
142 return $this->data['image'];
146 * Get the entry keywords
148 * @deprecated since 2.10.0; itunes:keywords is no longer part of the
149 * iTunes podcast RSS specification.
150 * @return string
152 public function getKeywords()
154 trigger_error(
155 'itunes:keywords has been deprecated in the iTunes podcast RSS specification,'
156 . ' and should not be relied on.',
157 \E_USER_DEPRECATED
160 if (isset($this->data['keywords'])) {
161 return $this->data['keywords'];
164 $keywords = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:keywords)');
166 if (! $keywords) {
167 $keywords = null;
170 $this->data['keywords'] = $keywords;
172 return $this->data['keywords'];
176 * Get the entry's new feed url
178 * @return string
180 public function getNewFeedUrl()
182 if (isset($this->data['new-feed-url'])) {
183 return $this->data['new-feed-url'];
186 $newFeedUrl = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:new-feed-url)');
188 if (! $newFeedUrl) {
189 $newFeedUrl = null;
192 $this->data['new-feed-url'] = $newFeedUrl;
194 return $this->data['new-feed-url'];
198 * Get the entry owner
200 * @return string
202 public function getOwner()
204 if (isset($this->data['owner'])) {
205 return $this->data['owner'];
208 $owner = null;
210 $email = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:email)');
211 $name = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:name)');
213 if (! empty($email)) {
214 $owner = $email . (empty($name) ? '' : ' (' . $name . ')');
215 } elseif (! empty($name)) {
216 $owner = $name;
219 if (! $owner) {
220 $owner = null;
223 $this->data['owner'] = $owner;
225 return $this->data['owner'];
229 * Get the entry subtitle
231 * @return string
233 public function getSubtitle()
235 if (isset($this->data['subtitle'])) {
236 return $this->data['subtitle'];
239 $subtitle = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:subtitle)');
241 if (! $subtitle) {
242 $subtitle = null;
245 $this->data['subtitle'] = $subtitle;
247 return $this->data['subtitle'];
251 * Get the entry summary
253 * @return string
255 public function getSummary()
257 if (isset($this->data['summary'])) {
258 return $this->data['summary'];
261 $summary = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:summary)');
263 if (! $summary) {
264 $summary = null;
267 $this->data['summary'] = $summary;
269 return $this->data['summary'];
273 * Get the type of podcast
275 * @return string One of "episodic" or "serial". Defaults to "episodic"
276 * if no itunes:type tag is encountered.
278 public function getPodcastType()
280 if (isset($this->data['podcastType'])) {
281 return $this->data['podcastType'];
284 $type = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:type)');
286 if (! $type) {
287 $type = 'episodic';
290 $this->data['podcastType'] = (string) $type;
292 return $this->data['podcastType'];
296 * Is the podcast complete (no more episodes will post)?
298 * @return bool
300 public function isComplete()
302 if (isset($this->data['complete'])) {
303 return $this->data['complete'];
306 $complete = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:complete)');
308 if (! $complete) {
309 $complete = false;
312 $this->data['complete'] = $complete === 'Yes';
314 return $this->data['complete'];
318 * Register iTunes namespace
321 protected function registerNamespaces()
323 $this->xpath->registerNamespace('itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd');