/src/Zend/Media/Id3/Frame/Tpos.php

http://php-reader.googlecode.com/ · PHP · 110 lines · 37 code · 9 blank · 64 comment · 1 complexity · e907e33f85c7233686ce0783b1d764d2 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 ID3
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: Tpos.php 273 2012-08-21 17:22:52Z svollbehr $
  21. */
  22. /**#@+ @ignore */
  23. require_once 'Zend/Media/Id3/TextFrame.php';
  24. /**#@-*/
  25. /**
  26. * The <i>Number of a set</i> frame is a numeric string that describes which part
  27. * of a set the audio came from. This frame is used if the source described in
  28. * the {@link Zend_Media_Id3_Frame_Talb TALB} frame is divided into several
  29. * mediums, e.g. a double CD. The value may be extended with a '/' character and
  30. * a numeric string containing the total number of parts in the set. E.g. '1/2'.
  31. *
  32. * @category Zend
  33. * @package Zend_Media
  34. * @subpackage ID3
  35. * @author Sven Vollbehr <sven@vollbehr.eu>
  36. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. * @version $Id: Tpos.php 273 2012-08-21 17:22:52Z svollbehr $
  39. */
  40. final class Zend_Media_Id3_Frame_Tpos extends Zend_Media_Id3_TextFrame
  41. {
  42. private $_number;
  43. private $_total;
  44. /**
  45. * Constructs the class with given parameters and parses object related
  46. * data.
  47. *
  48. * @param Zend_Io_Reader $reader The reader object.
  49. * @param Array $options The options array.
  50. */
  51. public function __construct($reader = null, &$options = array())
  52. {
  53. parent::__construct($reader, $options);
  54. if ($this->_reader === null) {
  55. return;
  56. }
  57. @list ($this->_number, $this->_total) = explode("/", $this->getText());
  58. }
  59. /**
  60. * Returns the number.
  61. *
  62. * @return integer
  63. */
  64. public function getNumber()
  65. {
  66. return intval($this->_number);
  67. }
  68. /**
  69. * Sets the number.
  70. *
  71. * @param integer $number The number.
  72. */
  73. public function setNumber($part)
  74. {
  75. $this->setText
  76. ($this->_number = strval($part) .
  77. ($this->_total ? '/' . $this->_total : ''),
  78. Zend_Media_Id3_Encoding::ISO88591);
  79. }
  80. /**
  81. * Returns the total number.
  82. *
  83. * @return integer
  84. */
  85. public function getTotal()
  86. {
  87. return intval($this->_total);
  88. }
  89. /**
  90. * Sets the total number.
  91. *
  92. * @param integer $total The total number.
  93. */
  94. public function setTotal($total)
  95. {
  96. $this->setText
  97. (($this->_number ? $this->_number : '?') . "/" .
  98. ($this->_total = strval($total)),
  99. Zend_Media_Id3_Encoding::ISO88591);
  100. }
  101. }