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
8 namespace Zend\Feed\Writer\Extension\GooglePlayPodcast
;
12 use Zend\Stdlib\StringUtils
;
13 use Zend\Stdlib\StringWrapper\StringWrapperInterface
;
18 * Array of Feed data for rendering by Extension's renderers
25 * Encoding of all text values
29 protected $encoding = 'UTF-8';
32 * The used string wrapper supporting encoding
34 * @var StringWrapperInterface
36 protected $stringWrapper;
38 public function __construct()
40 $this->stringWrapper
= StringUtils
::getWrapper($this->encoding
);
49 public function setEncoding($enc)
51 $this->stringWrapper
= StringUtils
::getWrapper($enc);
52 $this->encoding
= $enc;
61 public function getEncoding()
63 return $this->encoding
;
67 * Set a block value of "yes" or "no". You may also set an empty string.
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;
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;
108 * Set episode description
110 * @param string $value
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;
126 * Overloading to itunes specific setters
128 * @param string $method
129 * @param array $params
130 * @throws Writer\Exception\BadMethodCallException
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])
148 return $this->data
[$point];