diff vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Entry.php @ 2:5311817fb629

Theme updates
author Chris Cannam
date Tue, 10 Jul 2018 13:19:18 +0000
parents c75dbcec494b
children a9cd425dd02b
line wrap: on
line diff
--- a/vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Entry.php	Thu Jul 05 15:32:06 2018 +0100
+++ b/vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Entry.php	Tue Jul 10 13:19:18 2018 +0000
@@ -9,8 +9,8 @@
 
 namespace Zend\Feed\Writer\Extension\ITunes;
 
+use Zend\Feed\Uri;
 use Zend\Feed\Writer;
-use Zend\Feed\Writer\Extension;
 use Zend\Stdlib\StringUtils;
 use Zend\Stdlib\StringWrapper\StringWrapperInterface;
 
@@ -76,7 +76,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');
         }
@@ -115,7 +115,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,9 +132,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');
@@ -152,7 +152,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"');
         }
@@ -163,12 +163,20 @@
     /**
      * Set keywords
      *
+     * @deprecated since 2.10.0; itunes:keywords is no longer part of the
+     *     iTunes podcast RSS specification.
      * @param  array $value
      * @return Entry
      * @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');
@@ -219,6 +227,123 @@
     }
 
     /**
+     * Set entry image (icon)
+     *
+     * @param  string $value
+     * @return Feed
+     * @throws Writer\Exception\InvalidArgumentException
+     */
+    public function setItunesImage($value)
+    {
+        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'])) {
+            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)'
+            );
+        }
+
+        $this->data['image'] = $value;
+        return $this;
+    }
+
+    /**
+     * Set the episode number
+     *
+     * @param int $number
+     * @return self
+     * @throws Writer\Exception\InvalidArgumentException
+     */
+    public function setItunesEpisode($number)
+    {
+        if (! is_numeric($number) || is_float($number)) {
+            throw new Writer\Exception\InvalidArgumentException(sprintf(
+                'invalid parameter: "number" may only be an integer; received %s',
+                is_object($number) ? get_class($number) : gettype($number)
+            ));
+        }
+
+        $this->data['episode'] = (int) $number;
+
+        return $this;
+    }
+
+    /**
+     * Set the episode type
+     *
+     * @param string $type One of "full", "trailer", or "bonus".
+     * @return self
+     * @throws Writer\Exception\InvalidArgumentException
+     */
+    public function setItunesEpisodeType($type)
+    {
+        $validTypes = ['full', 'trailer', 'bonus'];
+        if (! in_array($type, $validTypes, true)) {
+            throw new Writer\Exception\InvalidArgumentException(sprintf(
+                'invalid parameter: "episodeType" MUST be one of the strings [%s]; received %s',
+                implode(', ', $validTypes),
+                is_object($type) ? get_class($type) : var_export($type, true)
+            ));
+        }
+
+        $this->data['episodeType'] = $type;
+
+        return $this;
+    }
+
+    /**
+     * Set the status of closed captioning
+     *
+     * @param bool $status
+     * @return self
+     * @throws Writer\Exception\InvalidArgumentException
+     */
+    public function setItunesIsClosedCaptioned($status)
+    {
+        if (! is_bool($status)) {
+            throw new Writer\Exception\InvalidArgumentException(sprintf(
+                'invalid parameter: "isClosedCaptioned" MUST be a boolean; received %s',
+                is_object($status) ? get_class($status) : var_export($status, true)
+            ));
+        }
+
+        if (! $status) {
+            return $this;
+        }
+
+        $this->data['isClosedCaptioned'] = true;
+
+        return $this;
+    }
+
+    /**
+     * Set the season number to which the episode belongs
+     *
+     * @param int $number
+     * @return self
+     * @throws Writer\Exception\InvalidArgumentException
+     */
+    public function setItunesSeason($number)
+    {
+        if (! is_numeric($number) || is_float($number)) {
+            throw new Writer\Exception\InvalidArgumentException(sprintf(
+                'invalid parameter: "season" may only be an integer; received %s',
+                is_object($number) ? get_class($number) : gettype($number)
+            ));
+        }
+
+        $this->data['season'] = (int) $number;
+
+        return $this;
+    }
+
+    /**
      * Overloading to itunes specific setters
      *
      * @param  string $method
@@ -229,14 +354,14 @@
     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)
+        if (! array_key_exists($point, $this->data)
             || empty($this->data[$point])
         ) {
             return;