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