Chris@0: data['encoding'] = $encoding; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the feed character encoding Chris@0: * Chris@0: * @return string|null Chris@0: */ Chris@0: public function getEncoding() Chris@0: { Chris@12: if (! array_key_exists('encoding', $this->data)) { Chris@0: return 'UTF-8'; Chris@0: } Chris@0: return $this->data['encoding']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Unset a specific data point Chris@0: * Chris@0: * @param string $name Chris@0: * @return Deleted Chris@0: */ Chris@0: public function remove($name) Chris@0: { Chris@0: if (isset($this->data[$name])) { Chris@0: unset($this->data[$name]); Chris@0: } Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set the current feed type being exported to "rss" or "atom". This allows Chris@0: * other objects to gracefully choose whether to execute or not, depending Chris@0: * on their appropriateness for the current type, e.g. renderers. Chris@0: * Chris@0: * @param string $type Chris@0: * @return Deleted Chris@0: */ Chris@0: public function setType($type) Chris@0: { Chris@0: $this->type = $type; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Retrieve the current or last feed type exported. Chris@0: * Chris@0: * @return string Value will be "rss" or "atom" Chris@0: */ Chris@0: public function getType() Chris@0: { Chris@0: return $this->type; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set reference Chris@0: * Chris@0: * @param $reference Chris@0: * @throws Exception\InvalidArgumentException Chris@0: * @return Deleted Chris@0: */ Chris@0: public function setReference($reference) Chris@0: { Chris@12: if (empty($reference) || ! is_string($reference)) { Chris@0: throw new Exception\InvalidArgumentException('Invalid parameter: reference must be a non-empty string'); Chris@0: } Chris@0: $this->data['reference'] = $reference; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return string Chris@0: */ Chris@0: public function getReference() Chris@0: { Chris@12: if (! array_key_exists('reference', $this->data)) { Chris@0: return; Chris@0: } Chris@0: return $this->data['reference']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set when Chris@0: * Chris@17: * @param null|int|DateTimeInterface $date Chris@0: * @throws Exception\InvalidArgumentException Chris@0: * @return Deleted Chris@0: */ Chris@0: public function setWhen($date = null) Chris@0: { Chris@0: if ($date === null) { Chris@0: $date = new DateTime(); Chris@17: } Chris@17: if (is_int($date)) { Chris@0: $date = new DateTime('@' . $date); Chris@17: } Chris@17: if (! $date instanceof DateTimeInterface) { Chris@0: throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp' Chris@0: . ' passed as parameter'); Chris@0: } Chris@0: $this->data['when'] = $date; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return DateTime Chris@0: */ Chris@0: public function getWhen() Chris@0: { Chris@12: if (! array_key_exists('when', $this->data)) { Chris@0: return; Chris@0: } Chris@0: return $this->data['when']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set by Chris@0: * Chris@0: * @param array $by Chris@0: * @throws Exception\InvalidArgumentException Chris@0: * @return Deleted Chris@0: */ Chris@0: public function setBy(array $by) Chris@0: { Chris@0: $author = []; Chris@12: if (! array_key_exists('name', $by) Chris@0: || empty($by['name']) Chris@12: || ! is_string($by['name']) Chris@0: ) { Chris@0: throw new Exception\InvalidArgumentException('Invalid parameter: author array must include a' Chris@0: . ' "name" key with a non-empty string value'); Chris@0: } Chris@0: $author['name'] = $by['name']; Chris@0: if (isset($by['email'])) { Chris@12: if (empty($by['email']) || ! is_string($by['email'])) { Chris@0: throw new Exception\InvalidArgumentException('Invalid parameter: "email" array' Chris@0: . ' value must be a non-empty string'); Chris@0: } Chris@0: $author['email'] = $by['email']; Chris@0: } Chris@0: if (isset($by['uri'])) { Chris@0: if (empty($by['uri']) Chris@12: || ! is_string($by['uri']) Chris@12: || ! Uri::factory($by['uri'])->isValid() Chris@0: ) { Chris@0: throw new Exception\InvalidArgumentException('Invalid parameter: "uri" array value must' Chris@0: . ' be a non-empty string and valid URI/IRI'); Chris@0: } Chris@0: $author['uri'] = $by['uri']; Chris@0: } Chris@0: $this->data['by'] = $author; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return string Chris@0: */ Chris@0: public function getBy() Chris@0: { Chris@12: if (! array_key_exists('by', $this->data)) { Chris@0: return; Chris@0: } Chris@0: return $this->data['by']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @param string $comment Chris@0: * @return Deleted Chris@0: */ Chris@0: public function setComment($comment) Chris@0: { Chris@0: $this->data['comment'] = $comment; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return string Chris@0: */ Chris@0: public function getComment() Chris@0: { Chris@12: if (! array_key_exists('comment', $this->data)) { Chris@0: return; Chris@0: } Chris@0: return $this->data['comment']; Chris@0: } Chris@0: }