/** * Save tag * * @throws \RuntimeException * * @return $this */ public function save() { $hydrator = new ClassMethods(); $properties = $hydrator->extract($this); $data = array(); unset($properties['audio_properties']); foreach ($properties as $name => $value) { if (null === $value) { continue; } switch ($name) { case 'track': if (null !== $properties['track_count']) { $value .= '/' . $properties['track_count']; } $data['track'] = array($value); break; case 'works': $data['content_group_description'] = array($value); break; case 'disc': if (null !== $properties['disc_count']) { $value .= '/' . $properties['disc_count']; } $data['part_of_a_set'] = array($value); break; case 'picture': /** @var \GravityMedia\Metadata\Feature\Picture $value */ $data['attached_picture'] = array(array('data' => $value->getData(), 'mime' => $value->getMime(), 'picturetypeid' => array_search($value->getPictureType(), GetId3::getId3v2PictureTypes()), 'description' => $value->getDescription())); break; default: $data[$name] = array($value); break; } } return $this->writer->write($data); }
/** * Set picture type * * @param string $pictureType * * @throws \BadMethodCallException * * @return $this */ public function setPictureType($pictureType) { if (!is_array($this->availablePictureTypes)) { $this->availablePictureTypes = array_values(GetId3::getId3v2PictureTypes()); } if (in_array($pictureType, $this->availablePictureTypes)) { $this->pictureType = $pictureType; return $this; } throw new \BadMethodCallException(sprintf('The picture type "%s" is not available', $pictureType)); }