PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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