2
0

TraitsInfo.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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_Amf
  17. * @subpackage Value
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * Zend_Amf_Value_TraitsInfo
  23. *
  24. * @package Zend_Amf
  25. * @subpackage Value
  26. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  27. * @license http://framework.zend.com/license/new-bsd New BSD License
  28. */
  29. class Zend_Amf_Value_TraitsInfo
  30. {
  31. /**
  32. * @var string Class name
  33. */
  34. protected $_className;
  35. /**
  36. * @var bool Whether or not this is a dynamic class
  37. */
  38. protected $_dynamic;
  39. /**
  40. * @var bool Whether or not the class is externalizable
  41. */
  42. protected $_externalizable;
  43. /**
  44. * @var array Class properties
  45. */
  46. protected $_properties;
  47. /**
  48. * Used to keep track of all class traits of an AMF3 object
  49. *
  50. * @param string $className
  51. * @param boolean $dynamic
  52. * @param boolean $externalizable
  53. * @param boolean $properties
  54. * @return void
  55. */
  56. public function __construct($className, $dynamic=false, $externalizable=false, $properties=null)
  57. {
  58. $this->_className = $className;
  59. $this->_dynamic = $dynamic;
  60. $this->_externalizable = $externalizable;
  61. $this->_properties = $properties;
  62. }
  63. /**
  64. * Test if the class is a dynamic class
  65. *
  66. * @return boolean
  67. */
  68. public function isDynamic()
  69. {
  70. return $this->_dynamic;
  71. }
  72. /**
  73. * Test if class is externalizable
  74. *
  75. * @return boolean
  76. */
  77. public function isExternalizable()
  78. {
  79. return $this->_externalizable;
  80. }
  81. /**
  82. * Return the number of properties in the class
  83. *
  84. * @return int
  85. */
  86. public function length()
  87. {
  88. return count($this->_properties);
  89. }
  90. /**
  91. * Return the class name
  92. *
  93. * @return string
  94. */
  95. public function getClassName()
  96. {
  97. return $this->_className;
  98. }
  99. /**
  100. * Add an additional property
  101. *
  102. * @param string $name
  103. * @return Zend_Amf_Value_TraitsInfo
  104. */
  105. public function addProperty($name)
  106. {
  107. $this->_properties[] = $name;
  108. return $this;
  109. }
  110. /**
  111. * Add all properties of the class.
  112. *
  113. * @param array $props
  114. * @return Zend_Amf_Value_TraitsInfo
  115. */
  116. public function addAllProperties(array $props)
  117. {
  118. $this->_properties = $props;
  119. return $this;
  120. }
  121. /**
  122. * Get the property at a given index
  123. *
  124. * @param int $index
  125. * @return string
  126. */
  127. public function getProperty($index)
  128. {
  129. return $this->_properties[(int) $index];
  130. }
  131. /**
  132. * Return all properties of the class.
  133. *
  134. * @return array
  135. */
  136. public function getAllProperties()
  137. {
  138. return $this->_properties;
  139. }
  140. }