Property.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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_Gdata
  17. * @subpackage Analytics
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Gdata_Extension
  24. */
  25. require_once 'Zend/Gdata/Extension.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Gdata
  29. * @subpackage Analytics
  30. */
  31. class Zend_Gdata_Analytics_Extension_Property extends Zend_Gdata_Extension
  32. {
  33. protected $_rootNamespace = 'ga';
  34. protected $_rootElement = 'property';
  35. protected $_value = null;
  36. protected $_name = null;
  37. /**
  38. * Constructs a new Zend_Gdata_Calendar_Extension_Timezone object.
  39. * @param string $value (optional) The text content of the element.
  40. */
  41. public function __construct($value = null, $name = null)
  42. {
  43. $this->registerAllNamespaces(Zend_Gdata_Analytics::$namespaces);
  44. parent::__construct();
  45. $this->_value = $value;
  46. $this->_name = $name;
  47. }
  48. /**
  49. * Given a DOMNode representing an attribute, tries to map the data into
  50. * instance members. If no mapping is defined, the name and value are
  51. * stored in an array.
  52. *
  53. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  54. */
  55. protected function takeAttributeFromDOM($attribute)
  56. {
  57. switch ($attribute->localName) {
  58. case 'name':
  59. $this->_name = substr($attribute->nodeValue, 3);
  60. break;
  61. case 'value':
  62. $this->_value = $attribute->nodeValue;
  63. break;
  64. default:
  65. parent::takeAttributeFromDOM($attribute);
  66. }
  67. }
  68. /**
  69. * Get the value for this element's value attribute.
  70. *
  71. * @return string The value associated with this attribute.
  72. */
  73. public function getValue()
  74. {
  75. return $this->_value;
  76. }
  77. /**
  78. * Set the value for this element's value attribute.
  79. *
  80. * @param string $value The desired value for this attribute.
  81. * @return Zend_Gdata_Analytics_Extension_Property The element being modified.
  82. */
  83. public function setValue($value)
  84. {
  85. $this->_value = $value;
  86. return $this;
  87. }
  88. /**
  89. * @param string $name
  90. * @return Zend_Gdata_Analytics_Extension_Property
  91. */
  92. public function setName($name)
  93. {
  94. $this->_name = $name;
  95. return $this;
  96. }
  97. /**
  98. * @return string
  99. */
  100. public function getName()
  101. {
  102. return $this->_name;
  103. }
  104. /**
  105. * Magic toString method allows using this directly via echo
  106. * Works best in PHP >= 4.2.0
  107. */
  108. public function __toString()
  109. {
  110. return $this->getValue();
  111. }
  112. }