Mercurial > hg > isophonics-drupal-site
comparison vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Entry.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | 7a779792577d |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
15:e200cb7efeb3 | 16:c2387f117808 |
---|---|
7 * @license http://framework.zend.com/license/new-bsd New BSD License | 7 * @license http://framework.zend.com/license/new-bsd New BSD License |
8 */ | 8 */ |
9 | 9 |
10 namespace Zend\Feed\Writer\Extension\ITunes; | 10 namespace Zend\Feed\Writer\Extension\ITunes; |
11 | 11 |
12 use Zend\Feed\Uri; | |
12 use Zend\Feed\Writer; | 13 use Zend\Feed\Writer; |
13 use Zend\Stdlib\StringUtils; | 14 use Zend\Stdlib\StringUtils; |
14 use Zend\Stdlib\StringWrapper\StringWrapperInterface; | 15 use Zend\Stdlib\StringWrapper\StringWrapperInterface; |
15 | 16 |
16 /** | 17 /** |
160 } | 161 } |
161 | 162 |
162 /** | 163 /** |
163 * Set keywords | 164 * Set keywords |
164 * | 165 * |
166 * @deprecated since 2.10.0; itunes:keywords is no longer part of the | |
167 * iTunes podcast RSS specification. | |
165 * @param array $value | 168 * @param array $value |
166 * @return Entry | 169 * @return Entry |
167 * @throws Writer\Exception\InvalidArgumentException | 170 * @throws Writer\Exception\InvalidArgumentException |
168 */ | 171 */ |
169 public function setItunesKeywords(array $value) | 172 public function setItunesKeywords(array $value) |
170 { | 173 { |
174 trigger_error( | |
175 'itunes:keywords has been deprecated in the iTunes podcast RSS specification,' | |
176 . ' and should not be relied on.', | |
177 \E_USER_DEPRECATED | |
178 ); | |
179 | |
171 if (count($value) > 12) { | 180 if (count($value) > 12) { |
172 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "keywords" may only' | 181 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "keywords" may only' |
173 . ' contain a maximum of 12 terms'); | 182 . ' contain a maximum of 12 terms'); |
174 } | 183 } |
175 | 184 |
212 if ($this->stringWrapper->strlen($value) > 4000) { | 221 if ($this->stringWrapper->strlen($value) > 4000) { |
213 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "summary" may only' | 222 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "summary" may only' |
214 . ' contain a maximum of 4000 characters'); | 223 . ' contain a maximum of 4000 characters'); |
215 } | 224 } |
216 $this->data['summary'] = $value; | 225 $this->data['summary'] = $value; |
226 return $this; | |
227 } | |
228 | |
229 /** | |
230 * Set entry image (icon) | |
231 * | |
232 * @param string $value | |
233 * @return Feed | |
234 * @throws Writer\Exception\InvalidArgumentException | |
235 */ | |
236 public function setItunesImage($value) | |
237 { | |
238 if (! is_string($value) || ! Uri::factory($value)->isValid()) { | |
239 throw new Writer\Exception\InvalidArgumentException( | |
240 'invalid parameter: "image" may only be a valid URI/IRI' | |
241 ); | |
242 } | |
243 | |
244 if (! in_array(substr($value, -3), ['jpg', 'png'])) { | |
245 throw new Writer\Exception\InvalidArgumentException( | |
246 'invalid parameter: "image" may only use file extension "jpg"' | |
247 . ' or "png" which must be the last three characters of the URI' | |
248 . ' (i.e. no query string or fragment)' | |
249 ); | |
250 } | |
251 | |
252 $this->data['image'] = $value; | |
253 return $this; | |
254 } | |
255 | |
256 /** | |
257 * Set the episode number | |
258 * | |
259 * @param int $number | |
260 * @return self | |
261 * @throws Writer\Exception\InvalidArgumentException | |
262 */ | |
263 public function setItunesEpisode($number) | |
264 { | |
265 if (! is_numeric($number) || is_float($number)) { | |
266 throw new Writer\Exception\InvalidArgumentException(sprintf( | |
267 'invalid parameter: "number" may only be an integer; received %s', | |
268 is_object($number) ? get_class($number) : gettype($number) | |
269 )); | |
270 } | |
271 | |
272 $this->data['episode'] = (int) $number; | |
273 | |
274 return $this; | |
275 } | |
276 | |
277 /** | |
278 * Set the episode type | |
279 * | |
280 * @param string $type One of "full", "trailer", or "bonus". | |
281 * @return self | |
282 * @throws Writer\Exception\InvalidArgumentException | |
283 */ | |
284 public function setItunesEpisodeType($type) | |
285 { | |
286 $validTypes = ['full', 'trailer', 'bonus']; | |
287 if (! in_array($type, $validTypes, true)) { | |
288 throw new Writer\Exception\InvalidArgumentException(sprintf( | |
289 'invalid parameter: "episodeType" MUST be one of the strings [%s]; received %s', | |
290 implode(', ', $validTypes), | |
291 is_object($type) ? get_class($type) : var_export($type, true) | |
292 )); | |
293 } | |
294 | |
295 $this->data['episodeType'] = $type; | |
296 | |
297 return $this; | |
298 } | |
299 | |
300 /** | |
301 * Set the status of closed captioning | |
302 * | |
303 * @param bool $status | |
304 * @return self | |
305 * @throws Writer\Exception\InvalidArgumentException | |
306 */ | |
307 public function setItunesIsClosedCaptioned($status) | |
308 { | |
309 if (! is_bool($status)) { | |
310 throw new Writer\Exception\InvalidArgumentException(sprintf( | |
311 'invalid parameter: "isClosedCaptioned" MUST be a boolean; received %s', | |
312 is_object($status) ? get_class($status) : var_export($status, true) | |
313 )); | |
314 } | |
315 | |
316 if (! $status) { | |
317 return $this; | |
318 } | |
319 | |
320 $this->data['isClosedCaptioned'] = true; | |
321 | |
322 return $this; | |
323 } | |
324 | |
325 /** | |
326 * Set the season number to which the episode belongs | |
327 * | |
328 * @param int $number | |
329 * @return self | |
330 * @throws Writer\Exception\InvalidArgumentException | |
331 */ | |
332 public function setItunesSeason($number) | |
333 { | |
334 if (! is_numeric($number) || is_float($number)) { | |
335 throw new Writer\Exception\InvalidArgumentException(sprintf( | |
336 'invalid parameter: "season" may only be an integer; received %s', | |
337 is_object($number) ? get_class($number) : gettype($number) | |
338 )); | |
339 } | |
340 | |
341 $this->data['season'] = (int) $number; | |
342 | |
217 return $this; | 343 return $this; |
218 } | 344 } |
219 | 345 |
220 /** | 346 /** |
221 * Overloading to itunes specific setters | 347 * Overloading to itunes specific setters |