TraitsInfo.php 3.4 KB

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