public function setAuthor($author, $email = null, $uri = null)
{
if ($this->version == Feed::RSS1) {
throw new InvalidOperationException('The author element is not supported in RSS1 feeds.');
}
// Regex from RFC 4287 page 41
if ($email != null && preg_match('/.+@.+/', $email) != 1) {
throw new \InvalidArgumentException('The email address is syntactically incorrect.');
}
if ($this->version == Feed::RSS2) {
if ($email != null) {
$author = $email . ' (' . $author . ')';
}
$this->addElement('author', $author);
} else {
$elements = array('name' => $author);
if ($email != null) {
$elements['email'] = $email;
}
if ($uri != null) {
$elements['uri'] = $uri;
}
$this->addElement('author', $elements);
}
return $this;
}