You are here

public function Entry::addAuthor in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-feed/src/Writer/Entry.php \Zend\Feed\Writer\Entry::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

Entry

Throws

Exception\InvalidArgumentException If any value of $author not follow the format.

1 call to Entry::addAuthor()
Entry::addAuthors in vendor/zendframework/zend-feed/src/Writer/Entry.php
Set an array with feed authors

File

vendor/zendframework/zend-feed/src/Writer/Entry.php, line 64

Class

Entry

Namespace

Zend\Feed\Writer

Code

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;
}