setOptions($options); if ($this->title === null) { throw new Exception\InvalidArgumentException('Title was not set'); } if ($this->weight === null) { throw new Exception\InvalidArgumentException('Weight was not set'); } } /** * Set options of the tag * * @param array $options * @return \Zend\Tag\Item */ public function setOptions(array $options) { foreach ($options as $key => $value) { if (in_array(strtolower($key), $this->skipOptions)) { continue; } $method = 'set' . $key; if (method_exists($this, $method)) { $this->$method($value); } } return $this; } /** * Defined by Zend\Tag\TaggableInterface * * @return string */ public function getTitle() { return $this->title; } /** * Set the title * * @param string $title * @throws \Zend\Tag\Exception\InvalidArgumentException When title is no string * @return \Zend\Tag\Item */ public function setTitle($title) { if (!is_string($title)) { throw new Exception\InvalidArgumentException('Title must be a string'); } $this->title = (string) $title; return $this; } /** * Defined by Zend\Tag\TaggableInterface * * @return float */ public function getWeight() { return $this->weight; } /** * Set the weight * * @param float $weight * @throws \Zend\Tag\Exception\InvalidArgumentException When weight is not numeric * @return \Zend\Tag\Item */ public function setWeight($weight) { if (!is_numeric($weight)) { throw new Exception\InvalidArgumentException('Weight must be numeric'); } $this->weight = (float) $weight; return $this; } /** * Set multiple params at once * * @param array $params * @return \Zend\Tag\Item */ public function setParams(array $params) { foreach ($params as $name => $value) { $this->setParam($name, $value); } return $this; } /** * Defined by Zend\Tag\TaggableInterface * * @param string $name * @param mixed $value * @return \Zend\Tag\Item */ public function setParam($name, $value) { $this->params[$name] = $value; return $this; } /** * Defined by Zend\Tag\TaggableInterface * * @param string $name * @return mixed */ public function getParam($name) { if (isset($this->params[$name])) { return $this->params[$name]; } return null; } }