composer package updates
[openemr.git] / vendor / zendframework / zend-feed / src / Writer / Extension / GooglePlayPodcast / Entry.php
blob1110c94657cc976a2fb4eba2e8c2c829e1a7bcfc
1 <?php
2 /**
3 * @see https://github.com/zendframework/zend-feed for the canonical source repository
4 * @copyright Copyright (c) 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\Writer\Extension\GooglePlayPodcast;
10 use Zend\Feed\Uri;
11 use Zend\Feed\Writer;
12 use Zend\Stdlib\StringUtils;
13 use Zend\Stdlib\StringWrapper\StringWrapperInterface;
15 class Entry
17 /**
18 * Array of Feed data for rendering by Extension's renderers
20 * @var array
22 protected $data = [];
24 /**
25 * Encoding of all text values
27 * @var string
29 protected $encoding = 'UTF-8';
31 /**
32 * The used string wrapper supporting encoding
34 * @var StringWrapperInterface
36 protected $stringWrapper;
38 public function __construct()
40 $this->stringWrapper = StringUtils::getWrapper($this->encoding);
43 /**
44 * Set feed encoding
46 * @param string $enc
47 * @return Entry
49 public function setEncoding($enc)
51 $this->stringWrapper = StringUtils::getWrapper($enc);
52 $this->encoding = $enc;
53 return $this;
56 /**
57 * Get feed encoding
59 * @return string
61 public function getEncoding()
63 return $this->encoding;
66 /**
67 * Set a block value of "yes" or "no". You may also set an empty string.
69 * @param string
70 * @return Entry
71 * @throws Writer\Exception\InvalidArgumentException
73 public function setPlayPodcastBlock($value)
75 if (! ctype_alpha($value) && strlen($value) > 0) {
76 throw new Writer\Exception\InvalidArgumentException(
77 'invalid parameter: "block" may only contain alphabetic characters'
81 if ($this->stringWrapper->strlen($value) > 255) {
82 throw new Writer\Exception\InvalidArgumentException(
83 'invalid parameter: "block" may only contain a maximum of 255 characters'
86 $this->data['block'] = $value;
89 /**
90 * Set "explicit" flag
92 * @param bool $value
93 * @return Entry
94 * @throws Writer\Exception\InvalidArgumentException
96 public function setPlayPodcastExplicit($value)
98 if (! in_array($value, ['yes', 'no', 'clean'], true)) {
99 throw new Writer\Exception\InvalidArgumentException(
100 'invalid parameter: "explicit" may only be one of "yes", "no" or "clean"'
103 $this->data['explicit'] = $value;
104 return $this;
108 * Set episode description
110 * @param string $value
111 * @return Entry
112 * @throws Writer\Exception\InvalidArgumentException
114 public function setPlayPodcastDescription($value)
116 if ($this->stringWrapper->strlen($value) > 4000) {
117 throw new Writer\Exception\InvalidArgumentException(
118 'invalid parameter: "description" may only contain a maximum of 4000 characters'
121 $this->data['description'] = $value;
122 return $this;
126 * Overloading to itunes specific setters
128 * @param string $method
129 * @param array $params
130 * @throws Writer\Exception\BadMethodCallException
131 * @return mixed
133 public function __call($method, array $params)
135 $point = lcfirst(substr($method, 14));
136 if (! method_exists($this, 'setPlayPodcast' . ucfirst($point))
137 && ! method_exists($this, 'addPlayPodcast' . ucfirst($point))
139 throw new Writer\Exception\BadMethodCallException(
140 'invalid method: ' . $method
143 if (! array_key_exists($point, $this->data)
144 || empty($this->data[$point])
146 return;
148 return $this->data[$point];