File indexing completed on 2024-06-16 05:30:08

0001 <?php
0002 
0003 /**
0004  * Zend Framework
0005  *
0006  * LICENSE
0007  *
0008  * This source file is subject to the new BSD license that is bundled
0009  * with this package in the file LICENSE.txt.
0010  * It is also available through the world-wide-web at this URL:
0011  * http://framework.zend.com/license/new-bsd
0012  * If you did not receive a copy of the license and are unable to
0013  * obtain it through the world-wide-web, please send an email
0014  * to license@zend.com so we can send you a copy immediately.
0015  *
0016  * @category   Zend
0017  * @package    Zend_Gdata
0018  * @subpackage Media
0019  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0020  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0021  * @version    $Id$
0022  */
0023 
0024 /**
0025  * @see Zend_Gdata_App_Extension
0026  */
0027 // require_once 'Zend/Gdata/App/Extension.php';
0028 
0029 /**
0030  * Represents the media:rating element
0031  *
0032  * @category   Zend
0033  * @package    Zend_Gdata
0034  * @subpackage Media
0035  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0036  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0037  */
0038 class Zend_Gdata_Media_Extension_MediaRating extends Zend_Gdata_Extension
0039 {
0040 
0041     protected $_rootElement = 'rating';
0042     protected $_rootNamespace = 'media';
0043 
0044     /**
0045      * @var string
0046      */
0047     protected $_scheme = null;
0048 
0049     /**
0050      * Constructs a new MediaRating element
0051      *
0052      * @param string $text
0053      * @param string $scheme
0054      */
0055     public function __construct($text = null, $scheme = null)
0056     {
0057         $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
0058         parent::__construct();
0059         $this->_scheme = $scheme;
0060         $this->_text = $text;
0061     }
0062 
0063     /**
0064      * Retrieves a DOMElement which corresponds to this element and all
0065      * child properties.  This is used to build an entry back into a DOM
0066      * and eventually XML text for sending to the server upon updates, or
0067      * for application storage/persistence.
0068      *
0069      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
0070      * @return DOMElement The DOMElement representing this element and all
0071      * child properties.
0072      */
0073     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0074     {
0075         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0076         if ($this->_scheme !== null) {
0077             $element->setAttribute('scheme', $this->_scheme);
0078         }
0079         return $element;
0080     }
0081 
0082     /**
0083      * Given a DOMNode representing an attribute, tries to map the data into
0084      * instance members.  If no mapping is defined, the name and value are
0085      * stored in an array.
0086      *
0087      * @param DOMNode $attribute The DOMNode attribute needed to be handled
0088      */
0089     protected function takeAttributeFromDOM($attribute)
0090     {
0091         switch ($attribute->localName) {
0092         case 'scheme':
0093             $this->_scheme = $attribute->nodeValue;
0094             break;
0095         default:
0096             parent::takeAttributeFromDOM($attribute);
0097         }
0098     }
0099 
0100     /**
0101      * @return string
0102      */
0103     public function getScheme()
0104     {
0105         return $this->_scheme;
0106     }
0107 
0108     /**
0109      * @param string $value
0110      * @return Zend_Gdata_Media_Extension_MediaRating Provides a fluent interface
0111      */
0112     public function setScheme($value)
0113     {
0114         $this->_scheme = $value;
0115         return $this;
0116     }
0117 
0118 }