Mercurial > hg > cmmr2012-drupal-site
diff vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Feed.php @ 2:5311817fb629
Theme updates
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 13:19:18 +0000 |
parents | c75dbcec494b |
children |
line wrap: on
line diff
--- a/vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Feed.php Thu Jul 05 15:32:06 2018 +0100 +++ b/vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Feed.php Tue Jul 10 13:19:18 2018 +0000 @@ -77,7 +77,7 @@ */ public function setItunesBlock($value) { - if (!ctype_alpha($value) && strlen($value) > 0) { + if (! ctype_alpha($value) && strlen($value) > 0) { throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only' . ' contain alphabetic characters'); } @@ -116,7 +116,7 @@ throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "author" may only' . ' contain a maximum of 255 characters each'); } - if (!isset($this->data['authors'])) { + if (! isset($this->data['authors'])) { $this->data['authors'] = []; } $this->data['authors'][] = $value; @@ -132,11 +132,11 @@ */ public function setItunesCategories(array $values) { - if (!isset($this->data['categories'])) { + if (! isset($this->data['categories'])) { $this->data['categories'] = []; } foreach ($values as $key => $value) { - if (!is_array($value)) { + if (! is_array($value)) { if ($this->stringWrapper->strlen($value) > 255) { throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "category" may only' . ' contain a maximum of 255 characters each'); @@ -169,11 +169,11 @@ */ public function setItunesImage($value) { - if (!Uri::factory($value)->isValid()) { + if (! is_string($value) || ! Uri::factory($value)->isValid()) { throw new Writer\Exception\InvalidArgumentException('invalid parameter: "image" may only' . ' be a valid URI/IRI'); } - if (!in_array(substr($value, -3), ['jpg', 'png'])) { + if (! in_array(substr($value, -3), ['jpg', 'png'])) { throw new Writer\Exception\InvalidArgumentException('invalid parameter: "image" may only' . ' use file extension "jpg" or "png" which must be the last three' . ' characters of the URI (i.e. no query string or fragment)'); @@ -192,9 +192,9 @@ public function setItunesDuration($value) { $value = (string) $value; - if (!ctype_digit($value) - && !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value) - && !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value) + if (! ctype_digit($value) + && ! preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value) + && ! preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value) ) { throw new Writer\Exception\InvalidArgumentException('invalid parameter: "duration" may only' . ' be of a specified [[HH:]MM:]SS format'); @@ -212,7 +212,7 @@ */ public function setItunesExplicit($value) { - if (!in_array($value, ['yes', 'no', 'clean'])) { + if (! in_array($value, ['yes', 'no', 'clean'])) { throw new Writer\Exception\InvalidArgumentException('invalid parameter: "explicit" may only' . ' be one of "yes", "no" or "clean"'); } @@ -223,12 +223,20 @@ /** * Set feed keywords * + * @deprecated since 2.10.0; itunes:keywords is no longer part of the + * iTunes podcast RSS specification. * @param array $value * @return Feed * @throws Writer\Exception\InvalidArgumentException */ public function setItunesKeywords(array $value) { + trigger_error( + 'itunes:keywords has been deprecated in the iTunes podcast RSS specification,' + . ' and should not be relied on.', + \E_USER_DEPRECATED + ); + if (count($value) > 12) { throw new Writer\Exception\InvalidArgumentException('invalid parameter: "keywords" may only' . ' contain a maximum of 12 terms'); @@ -252,7 +260,7 @@ */ public function setItunesNewFeedUrl($value) { - if (!Uri::factory($value)->isValid()) { + if (! Uri::factory($value)->isValid()) { throw new Writer\Exception\InvalidArgumentException('invalid parameter: "newFeedUrl" may only' . ' be a valid URI/IRI'); } @@ -283,7 +291,7 @@ */ public function addItunesOwner(array $value) { - if (!isset($value['name']) || !isset($value['email'])) { + if (! isset($value['name']) || ! isset($value['email'])) { throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "owner" must' . ' be an array containing keys "name" and "email"'); } @@ -293,7 +301,7 @@ throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "owner" may only' . ' contain a maximum of 255 characters each for "name" and "email"'); } - if (!isset($this->data['owners'])) { + if (! isset($this->data['owners'])) { $this->data['owners'] = []; } $this->data['owners'][] = $value; @@ -335,6 +343,51 @@ } /** + * Set podcast type + * + * @param string $type + * @return Feed + * @throws Writer\Exception\InvalidArgumentException + */ + public function setItunesType($type) + { + $validTypes = ['episodic', 'serial']; + if (! in_array($type, $validTypes, true)) { + throw new Writer\Exception\InvalidArgumentException(sprintf( + 'invalid parameter: "type" MUST be one of [%s]; received %s', + implode(', ', $validTypes), + is_object($type) ? get_class($type) : var_export($type, true) + )); + } + $this->data['type'] = $type; + return $this; + } + + /** + * Set "completion" status (whether more episodes will be released) + * + * @param bool $status + * @return Feed + * @throws Writer\Exception\InvalidArgumentException + */ + public function setItunesComplete($status) + { + if (! is_bool($status)) { + throw new Writer\Exception\InvalidArgumentException(sprintf( + 'invalid parameter: "complete" MUST be boolean; received %s', + is_object($status) ? get_class($status) : var_export($status, true) + )); + } + + if (! $status) { + return $this; + } + + $this->data['complete'] = 'Yes'; + return $this; + } + + /** * Overloading: proxy to internal setters * * @param string $method @@ -345,14 +398,15 @@ public function __call($method, array $params) { $point = lcfirst(substr($method, 9)); - if (!method_exists($this, 'setItunes' . ucfirst($point)) - && !method_exists($this, 'addItunes' . ucfirst($point)) + if (! method_exists($this, 'setItunes' . ucfirst($point)) + && ! method_exists($this, 'addItunes' . ucfirst($point)) ) { throw new Writer\Exception\BadMethodCallException( 'invalid method: ' . $method ); } - if (!array_key_exists($point, $this->data) || empty($this->data[$point])) { + + if (! array_key_exists($point, $this->data) || empty($this->data[$point])) { return; } return $this->data[$point];