PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Zend/Media/Flac/MetadataBlock/VorbisComment.php

http://php-reader.googlecode.com/
PHP | 155 lines | 70 code | 8 blank | 77 comment | 5 complexity | 62297810a2b4d856add01afdb534a0b7 MD5 | raw file
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Media
  17. * @subpackage FLAC
  18. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: VorbisComment.php 251 2011-06-13 15:41:51Z svollbehr $
  21. */
  22. /**#@+ @ignore */
  23. require_once 'Zend/Media/Flac/MetadataBlock.php';
  24. require_once 'Zend/Media/Vorbis/Header/Comment.php';
  25. /**#@-*/
  26. /**
  27. * This class represents the vorbis comments metadata block. This block is for storing a list of human-readable
  28. * name/value pairs. This is the only officially supported tagging mechanism in FLAC. There may be only one
  29. * VORBIS_COMMENT block in a stream. In some external documentation, Vorbis comments are called FLAC tags to lessen
  30. * confusion.
  31. *
  32. * This class parses the vorbis comments using the {@link Zend_Media_Vorbis_Header_Comment} class. Any of its method
  33. * or fields can be used in the context of this class.
  34. *
  35. * @category Zend
  36. * @package Zend_Media
  37. * @subpackage FLAC
  38. * @author Sven Vollbehr <sven@vollbehr.eu>
  39. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  40. * @license http://framework.zend.com/license/new-bsd New BSD License
  41. * @version $Id: VorbisComment.php 251 2011-06-13 15:41:51Z svollbehr $
  42. */
  43. final class Zend_Media_Flac_MetadataBlock_VorbisComment extends Zend_Media_Flac_MetadataBlock
  44. {
  45. /** @var Zend_Media_Vorbis_Header_Comment */
  46. private $_impl;
  47. /**
  48. * Constructs the class with given parameters and parses object related data using the vorbis comment implementation
  49. * class {@link Zend_Media_Vorbis_Header_Comment}.
  50. *
  51. * @param Zend_Io_Reader $reader The reader object.
  52. */
  53. public function __construct($reader)
  54. {
  55. parent::__construct($reader);
  56. $this->_impl = new Zend_Media_Vorbis_Header_Comment($this->_reader, array('vorbisContext' => false));
  57. }
  58. /**
  59. * Forward all calls to the vorbis comment implementation class {@link Zend_Media_Vorbis_Header_Comment}.
  60. *
  61. * @param string $name The method name.
  62. * @param Array $arguments The method arguments.
  63. * @return mixed
  64. */
  65. public function __call($name, $arguments)
  66. {
  67. if (method_exists($this, $name)) {
  68. return call_user_func(array($this, $name), $arguments);
  69. }
  70. try {
  71. return $this->_impl->$name($arguments);
  72. } catch (Zend_Media_Vorbis_Exception $e) {
  73. require_once 'Zend/Media/Flac/Exception.php';
  74. throw new Zend_Media_Flac_Exception($e->getMessage());
  75. }
  76. }
  77. /**
  78. * Forward all calls to the vorbis comment implementation class {@link Zend_Media_Vorbis_Header_Comment}.
  79. *
  80. * @param string $name The field name.
  81. * @return mixed
  82. */
  83. public function __get($name)
  84. {
  85. if (method_exists($this, 'get' . ucfirst($name))) {
  86. return call_user_func(array($this, 'get' . ucfirst($name)));
  87. }
  88. if (method_exists($this->_impl, 'get' . ucfirst($name))) {
  89. return call_user_func(array($this->_impl, 'get' . ucfirst($name)));
  90. }
  91. try {
  92. return $this->_impl->__get($name);
  93. } catch (Zend_Media_Vorbis_Exception $e) {
  94. require_once 'Zend/Media/Flac/Exception.php';
  95. throw new Zend_Media_Flac_Exception($e->getMessage());
  96. }
  97. }
  98. /**
  99. * Forward all calls to the vorbis comment implementation class {@link Zend_Media_Vorbis_Header_Comment}.
  100. *
  101. * @param string $name The field name.
  102. * @param string $name The field value.
  103. * @return mixed
  104. */
  105. public function __set($name, $value)
  106. {
  107. if (method_exists($this, 'set' . ucfirst($name))) {
  108. call_user_func(array($this, 'set' . ucfirst($name)), $value);
  109. } else {
  110. try {
  111. return $this->_impl->__set($name, $value);
  112. } catch (Zend_Media_Vorbis_Exception $e) {
  113. require_once 'Zend/Media/Flac/Exception.php';
  114. throw new Zend_Media_Flac_Exception($e->getMessage());
  115. }
  116. }
  117. }
  118. /**
  119. * Forward all calls to the vorbis comment implementation class {@link Zend_Media_Vorbis_Header_Comment}.
  120. *
  121. * @param string $name The field name.
  122. * @return boolean
  123. */
  124. public function __isset($name)
  125. {
  126. try {
  127. return $this->_impl->__isset($name);
  128. } catch (Zend_Media_Vorbis_Exception $e) {
  129. require_once 'Zend/Media/Flac/Exception.php';
  130. throw new Zend_Media_Flac_Exception($e->getMessage());
  131. }
  132. }
  133. /**
  134. * Forward all calls to the vorbis comment implementation class {@link Zend_Media_Vorbis_Header_Comment}.
  135. *
  136. * @param string $name The field name.
  137. */
  138. public function __unset($name)
  139. {
  140. try {
  141. $this->_impl->__unset($name);
  142. } catch (Zend_Media_Vorbis_Exception $e) {
  143. require_once 'Zend/Media/Flac/Exception.php';
  144. throw new Zend_Media_Flac_Exception($e->getMessage());
  145. }
  146. }
  147. }