You are here

public function Entry::setEnclosure in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-feed/src/Writer/Entry.php \Zend\Feed\Writer\Entry::setEnclosure()

Adds an enclosure to the entry. The array parameter may contain the keys 'uri', 'type' and 'length'. Only 'uri' is required for Atom, though the others must also be provided or RSS rendering (where they are required) will throw an Exception.

Parameters

array $enclosure:

Return value

Entry

Throws

Exception\InvalidArgumentException

File

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

Class

Entry

Namespace

Zend\Feed\Writer

Code

public function setEnclosure(array $enclosure) {
  if (!isset($enclosure['uri'])) {
    throw new Exception\InvalidArgumentException('Enclosure "uri" is not set');
  }
  if (!Uri::factory($enclosure['uri'])
    ->isValid()) {
    throw new Exception\InvalidArgumentException('Enclosure "uri" is not a valid URI/IRI');
  }
  $this->data['enclosure'] = $enclosure;
  return $this;
}