Chris@16: stringWrapper = StringUtils::getWrapper($this->encoding); Chris@16: } Chris@16: Chris@16: /** Chris@16: * Set feed encoding Chris@16: * Chris@16: * @param string $enc Chris@16: * @return Feed Chris@16: */ Chris@16: public function setEncoding($enc) Chris@16: { Chris@16: $this->stringWrapper = StringUtils::getWrapper($enc); Chris@16: $this->encoding = $enc; Chris@16: return $this; Chris@16: } Chris@16: Chris@16: /** Chris@16: * Get feed encoding Chris@16: * Chris@16: * @return string Chris@16: */ Chris@16: public function getEncoding() Chris@16: { Chris@16: return $this->encoding; Chris@16: } Chris@16: Chris@16: /** Chris@16: * Set a block value of "yes" or "no". You may also set an empty string. Chris@16: * Chris@16: * @param string Chris@16: * @return Feed Chris@16: * @throws Writer\Exception\InvalidArgumentException Chris@16: */ Chris@16: public function setPlayPodcastBlock($value) Chris@16: { Chris@16: if (! ctype_alpha($value) && strlen($value) > 0) { Chris@16: throw new Writer\Exception\InvalidArgumentException( Chris@16: 'invalid parameter: "block" may only contain alphabetic characters' Chris@16: ); Chris@16: } Chris@16: if ($this->stringWrapper->strlen($value) > 255) { Chris@16: throw new Writer\Exception\InvalidArgumentException( Chris@16: 'invalid parameter: "block" may only contain a maximum of 255 characters' Chris@16: ); Chris@16: } Chris@16: $this->data['block'] = $value; Chris@16: return $this; Chris@16: } Chris@16: Chris@16: /** Chris@16: * Add feed authors Chris@16: * Chris@16: * @param array $values Chris@16: * @return Feed Chris@16: */ Chris@16: public function addPlayPodcastAuthors(array $values) Chris@16: { Chris@16: foreach ($values as $value) { Chris@16: $this->addPlayPodcastAuthor($value); Chris@16: } Chris@16: return $this; Chris@16: } Chris@16: Chris@16: /** Chris@16: * Add feed author Chris@16: * Chris@16: * @param string $value Chris@16: * @return Feed Chris@16: * @throws Writer\Exception\InvalidArgumentException Chris@16: */ Chris@16: public function addPlayPodcastAuthor($value) Chris@16: { Chris@16: if ($this->stringWrapper->strlen($value) > 255) { Chris@16: throw new Writer\Exception\InvalidArgumentException( Chris@16: 'invalid parameter: any "author" may only contain a maximum of 255 characters each' Chris@16: ); Chris@16: } Chris@16: if (! isset($this->data['authors'])) { Chris@16: $this->data['authors'] = []; Chris@16: } Chris@16: $this->data['authors'][] = $value; Chris@16: return $this; Chris@16: } Chris@16: Chris@16: /** Chris@16: * Set feed categories Chris@16: * Chris@16: * @param array $values Chris@16: * @return Feed Chris@16: * @throws Writer\Exception\InvalidArgumentException Chris@16: */ Chris@16: public function setPlayPodcastCategories(array $values) Chris@16: { Chris@16: if (! isset($this->data['categories'])) { Chris@16: $this->data['categories'] = []; Chris@16: } Chris@16: foreach ($values as $key => $value) { Chris@16: if (! is_array($value)) { Chris@16: if ($this->stringWrapper->strlen($value) > 255) { Chris@16: throw new Writer\Exception\InvalidArgumentException( Chris@16: 'invalid parameter: any "category" may only contain a maximum of 255 characters each' Chris@16: ); Chris@16: } Chris@16: $this->data['categories'][] = $value; Chris@16: } else { Chris@16: if ($this->stringWrapper->strlen($key) > 255) { Chris@16: throw new Writer\Exception\InvalidArgumentException( Chris@16: 'invalid parameter: any "category" may only contain a maximum of 255 characters each' Chris@16: ); Chris@16: } Chris@16: $this->data['categories'][$key] = []; Chris@16: foreach ($value as $val) { Chris@16: if ($this->stringWrapper->strlen($val) > 255) { Chris@16: throw new Writer\Exception\InvalidArgumentException( Chris@16: 'invalid parameter: any "category" may only contain a maximum of 255 characters each' Chris@16: ); Chris@16: } Chris@16: $this->data['categories'][$key][] = $val; Chris@16: } Chris@16: } Chris@16: } Chris@16: return $this; Chris@16: } Chris@16: Chris@16: /** Chris@16: * Set feed image (icon) Chris@16: * Chris@16: * @param string $value Chris@16: * @return Feed Chris@16: * @throws Writer\Exception\InvalidArgumentException Chris@16: */ Chris@16: public function setPlayPodcastImage($value) Chris@16: { Chris@16: if (! is_string($value) || ! Uri::factory($value)->isValid()) { Chris@16: throw new Writer\Exception\InvalidArgumentException( Chris@16: 'invalid parameter: "image" may only be a valid URI/IRI' Chris@16: ); Chris@16: } Chris@16: $this->data['image'] = $value; Chris@16: return $this; Chris@16: } Chris@16: Chris@16: /** Chris@16: * Set "explicit" flag Chris@16: * Chris@16: * @param bool $value Chris@16: * @return Feed Chris@16: * @throws Writer\Exception\InvalidArgumentException Chris@16: */ Chris@16: public function setPlayPodcastExplicit($value) Chris@16: { Chris@16: if (! in_array($value, ['yes', 'no', 'clean'], true)) { Chris@16: throw new Writer\Exception\InvalidArgumentException( Chris@16: 'invalid parameter: "explicit" may only be one of "yes", "no" or "clean"' Chris@16: ); Chris@16: } Chris@16: $this->data['explicit'] = $value; Chris@16: return $this; Chris@16: } Chris@16: Chris@16: /** Chris@16: * Set podcast description Chris@16: * Chris@16: * @param string $value Chris@16: * @return Feed Chris@16: * @throws Writer\Exception\InvalidArgumentException Chris@16: */ Chris@16: public function setPlayPodcastDescription($value) Chris@16: { Chris@16: if ($this->stringWrapper->strlen($value) > 4000) { Chris@16: throw new Writer\Exception\InvalidArgumentException( Chris@16: 'invalid parameter: "description" may only contain a maximum of 4000 characters' Chris@16: ); Chris@16: } Chris@16: $this->data['description'] = $value; Chris@16: return $this; Chris@16: } Chris@16: Chris@16: /** Chris@16: * Overloading: proxy to internal setters Chris@16: * Chris@16: * @param string $method Chris@16: * @param array $params Chris@16: * @return mixed Chris@16: * @throws Writer\Exception\BadMethodCallException Chris@16: */ Chris@16: public function __call($method, array $params) Chris@16: { Chris@16: $point = lcfirst(substr($method, 14)); Chris@16: if (! method_exists($this, 'setPlayPodcast' . ucfirst($point)) Chris@16: && ! method_exists($this, 'addPlayPodcast' . ucfirst($point)) Chris@16: ) { Chris@16: throw new Writer\Exception\BadMethodCallException( Chris@16: 'invalid method: ' . $method Chris@16: ); Chris@16: } Chris@16: Chris@16: if (! array_key_exists($point, $this->data) || empty($this->data[$point])) { Chris@16: return; Chris@16: } Chris@16: return $this->data[$point]; Chris@16: } Chris@16: }