8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
25 * @see Zend_Gdata_Extension
27 require_once 'Zend/Gdata/Extension.php';
30 * Represents the media:rating element specific to YouTube.
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
36 * @license http://framework.zend.com/license/new-bsd New BSD License
38 class Zend_Gdata_YouTube_Extension_MediaRating extends Zend_Gdata_Extension
41 protected $_rootElement = 'rating';
42 protected $_rootNamespace = 'media';
47 protected $_scheme = null;
52 protected $_country = null;
55 * Constructs a new MediaRating element
58 * @param string $scheme
59 * @param string $country
61 public function __construct($text = null, $scheme = null, $country = null)
63 $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
64 parent::__construct();
65 $this->_scheme = $scheme;
66 $this->_country = $country;
71 * Retrieves a DOMElement which corresponds to this element and all
72 * child properties. This is used to build an entry back into a DOM
73 * and eventually XML text for sending to the server upon updates, or
74 * for application storage/persistence.
76 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
77 * @return DOMElement The DOMElement representing this element and all
80 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
82 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
83 if ($this->_scheme !== null) {
84 $element->setAttribute('scheme', $this->_scheme);
86 if ($this->_country != null) {
87 $element->setAttribute('country', $this->_country);
93 * Given a DOMNode representing an attribute, tries to map the data into
94 * instance members. If no mapping is defined, the name and value are
97 * @param DOMNode $attribute The DOMNode attribute needed to be handled
99 protected function takeAttributeFromDOM($attribute)
101 switch ($attribute->localName) {
103 $this->_scheme = $attribute->nodeValue;
106 $this->_country = $attribute->nodeValue;
109 parent::takeAttributeFromDOM($attribute);
116 public function getScheme()
118 return $this->_scheme;
122 * @param string $value
123 * @return Zend_Gdata_YouTube_Extension_MediaRating Provides a fluent interface
125 public function setScheme($value)
127 $this->_scheme = $value;
134 public function getCountry()
136 return $this->_country;
140 * @param string $value
141 * @return Zend_Gdata_YouTube_Extension_MediaRating Provides a fluent interface
143 public function setCountry($value)
145 $this->_country = $value;