You are here

public function Feed::setItunesCategories in Zircon Profile 8

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

Set feed categories

Parameters

array $values:

Return value

Feed

Throws

Writer\Exception\InvalidArgumentException

File

vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Feed.php, line 135

Class

Feed

Namespace

Zend\Feed\Writer\Extension\ITunes

Code

public function setItunesCategories(array $values) {
  if (!isset($this->data['categories'])) {
    $this->data['categories'] = [];
  }
  foreach ($values as $key => $value) {
    if (!is_array($value)) {
      if ($this->stringWrapper
        ->strlen($value) > 255) {
        throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "category" may only' . ' contain a maximum of 255 characters each');
      }
      $this->data['categories'][] = $value;
    }
    else {
      if ($this->stringWrapper
        ->strlen($key) > 255) {
        throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "category" may only' . ' contain a maximum of 255 characters each');
      }
      $this->data['categories'][$key] = [];
      foreach ($value as $val) {
        if ($this->stringWrapper
          ->strlen($val) > 255) {
          throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "category" may only' . ' contain a maximum of 255 characters each');
        }
        $this->data['categories'][$key][] = $val;
      }
    }
  }
  return $this;
}