PageRenderTime 31ms CodeModel.GetById 20ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://php-reader.googlecode.com/
PHP | 105 lines | 36 code | 7 blank | 62 comment | 0 complexity | c6cb48245e90da03872557a17245a892 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: Time.php 177 2010-03-09 13:13:34Z svollbehr $
 21 * @deprecated ID3v2.3.0
 22 */
 23
 24/**#@+ @ignore */
 25require_once 'Zend/Media/Id3/DateFrame.php';
 26/**#@-*/
 27
 28/**
 29 * The <i>Time</i> frame contains the time for the recording in the HHMM format.
 30 *
 31 * @category   Zend
 32 * @package    Zend_Media
 33 * @subpackage ID3
 34 * @author     Sven Vollbehr <sven@vollbehr.eu>
 35 * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) 
 36 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 37 * @version    $Id: Time.php 177 2010-03-09 13:13:34Z svollbehr $
 38 * @deprecated ID3v2.3.0
 39 */
 40final class Zend_Media_Id3_Frame_Time extends Zend_Media_Id3_DateFrame
 41{
 42    private $_hours;
 43    private $_minutes;
 44
 45    /**
 46     * Constructs the class with given parameters and parses object related
 47     * data.
 48     *
 49     * @param Zend_Io_Reader $reader The reader object.
 50     * @param Array $options The options array.
 51     */
 52    public function __construct($reader = null, &$options = array())
 53    {
 54        parent::__construct($reader, $options, 'HHmm');
 55        $this->_hours = substr($this->getText(), 0, 2);
 56        $this->_minutes = substr($this->getText(), 2, 2);
 57    }
 58
 59    /**
 60     * Returns the hour.
 61     *
 62     * @return integer
 63     */
 64    public function getHour()
 65    {
 66        return intval($this->_hours);
 67    }
 68
 69    /**
 70     * Sets the hour.
 71     *
 72     * @param integer $hours The hours.
 73     */
 74    public function setHour($hours)
 75    {
 76        $this->setText
 77            (($this->_hours = str_pad(strval($hours), 2, "0", STR_PAD_LEFT)) .
 78             ($this->_minutes ? $this->_minutes : '00'),
 79             Zend_Media_Id3_Encoding::ISO88591);
 80    }
 81
 82    /**
 83     * Returns the minutes.
 84     *
 85     * @return integer
 86     */
 87    public function getMinute()
 88    {
 89        return intval($this->_minutes);
 90    }
 91
 92    /**
 93     * Sets the minutes.
 94     *
 95     * @param integer $minutes The minutes.
 96     */
 97    public function setMinute($minutes)
 98    {
 99        $this->setText
100            (($this->_hours ? $this->_hours : '00') .
101             ($this->_minutes =
102                  str_pad(strval($minutes), 2, "0", STR_PAD_LEFT)),
103             Zend_Media_Id3_Encoding::ISO88591);
104    }
105}