Property.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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-2015 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. $name = explode(':', $attribute->nodeValue);
  60. $this->_name = end($name);
  61. break;
  62. case 'value':
  63. $this->_value = $attribute->nodeValue;
  64. break;
  65. default:
  66. parent::takeAttributeFromDOM($attribute);
  67. }
  68. }
  69. /**
  70. * Get the value for this element's value attribute.
  71. *
  72. * @return string The value associated with this attribute.
  73. */
  74. public function getValue()
  75. {
  76. return $this->_value;
  77. }
  78. /**
  79. * Set the value for this element's value attribute.
  80. *
  81. * @param string $value The desired value for this attribute.
  82. * @return Zend_Gdata_Analytics_Extension_Property The element being modified.
  83. */
  84. public function setValue($value)
  85. {
  86. $this->_value = $value;
  87. return $this;
  88. }
  89. /**
  90. * @param string $name
  91. * @return Zend_Gdata_Analytics_Extension_Property
  92. */
  93. public function setName($name)
  94. {
  95. $this->_name = $name;
  96. return $this;
  97. }
  98. /**
  99. * @return string
  100. */
  101. public function getName()
  102. {
  103. return $this->_name;
  104. }
  105. /**
  106. * Magic toString method allows using this directly via echo
  107. * Works best in PHP >= 4.2.0
  108. */
  109. public function __toString()
  110. {
  111. return $this->getValue();
  112. }
  113. }