public function AbstractFeed::addAuthor in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/zendframework/zend-feed/src/Writer/AbstractFeed.php \Zend\Feed\Writer\AbstractFeed::addAuthor()
Set a single author
The following option keys are supported: 'name' => (string) The name 'email' => (string) An optional email 'uri' => (string) An optional and valid URI
Parameters
array $author:
Return value
Throws
Exception\InvalidArgumentException If any value of $author not follow the format.
1 call to AbstractFeed::addAuthor()
- AbstractFeed::addAuthors in vendor/
zendframework/ zend-feed/ src/ Writer/ AbstractFeed.php - Set an array with feed authors
File
- vendor/
zendframework/ zend-feed/ src/ Writer/ AbstractFeed.php, line 61
Class
Namespace
Zend\Feed\WriterCode
public function addAuthor(array $author) {
// Check array values
if (!array_key_exists('name', $author) || empty($author['name']) || !is_string($author['name'])) {
throw new Exception\InvalidArgumentException('Invalid parameter: author array must include a "name" key with a non-empty string value');
}
if (isset($author['email'])) {
if (empty($author['email']) || !is_string($author['email'])) {
throw new Exception\InvalidArgumentException('Invalid parameter: "email" array value must be a non-empty string');
}
}
if (isset($author['uri'])) {
if (empty($author['uri']) || !is_string($author['uri']) || !Uri::factory($author['uri'])
->isValid()) {
throw new Exception\InvalidArgumentException('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI');
}
}
$this->data['authors'][] = $author;
return $this;
}