Attribute.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_Service_Amazon
  17. * @subpackage SimpleDb
  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: Response.php 17539 2009-08-10 22:51:26Z mikaelkael $
  21. */
  22. /**
  23. * @category Zend
  24. * @package Zend_Service_Amazon
  25. * @subpackage SimpleDb
  26. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  27. * @license http://framework.zend.com/license/new-bsd New BSD License
  28. */
  29. class Zend_Service_Amazon_SimpleDb_Attribute
  30. {
  31. protected $_itemName;
  32. protected $_name;
  33. protected $_values;
  34. /**
  35. * Constructor
  36. *
  37. * @param string $itemName
  38. * @param string $name
  39. * @param array $values
  40. * @return void
  41. */
  42. function __construct($itemName, $name, $values)
  43. {
  44. $this->_itemName = $itemName;
  45. $this->_name = $name;
  46. if (!is_array($values)) {
  47. $this->_values = array($values);
  48. } else {
  49. $this->_values = $values;
  50. }
  51. }
  52. /**
  53. * Return the item name to which the attribute belongs
  54. *
  55. * @return string
  56. */
  57. public function getItemName ()
  58. {
  59. return $this->_itemName;
  60. }
  61. /**
  62. * Retrieve attribute values
  63. *
  64. * @return array
  65. */
  66. public function getValues()
  67. {
  68. return $this->_values;
  69. }
  70. /**
  71. * Retrieve the attribute name
  72. *
  73. * @return string
  74. */
  75. public function getName ()
  76. {
  77. return $this->_name;
  78. }
  79. /**
  80. * Add value
  81. *
  82. * @param mixed $value
  83. * @return void
  84. */
  85. public function addValue($value)
  86. {
  87. if (is_array($value)) {
  88. $this->_values += $value;
  89. } else {
  90. $this->_values[] = $value;
  91. }
  92. }
  93. public function setValues($values)
  94. {
  95. if (!is_array($values)) {
  96. $values = array($values);
  97. }
  98. $this->_values = $values;
  99. }
  100. }