NodeSet.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\DB\Tree;
  7. /**
  8. * TODO implements iterators
  9. *
  10. * @deprecated 102.0.0 Not used anymore.
  11. */
  12. class NodeSet implements \Iterator, \Countable
  13. {
  14. /**
  15. * @var Node[]
  16. */
  17. private $_nodes;
  18. /**
  19. * @var int
  20. */
  21. private $_current;
  22. /**
  23. * @var int
  24. */
  25. private $_currentNode;
  26. /**
  27. * @var int
  28. */
  29. private $count;
  30. /**
  31. * Constructor
  32. *
  33. * @deprecated 102.0.0
  34. */
  35. public function __construct()
  36. {
  37. $this->_nodes = [];
  38. $this->_current = 0;
  39. $this->_currentNode = 0;
  40. $this->count = 0;
  41. }
  42. /**
  43. * @param Node $node
  44. * @return int
  45. *
  46. * @deprecated 102.0.0
  47. */
  48. public function addNode(Node $node)
  49. {
  50. $this->_nodes[$this->_currentNode] = $node;
  51. $this->count++;
  52. return ++$this->_currentNode;
  53. }
  54. /**
  55. * @return int
  56. *
  57. * @deprecated 102.0.0
  58. */
  59. public function count()
  60. {
  61. return $this->count;
  62. }
  63. /**
  64. * @return bool
  65. *
  66. * @deprecated 102.0.0
  67. */
  68. public function valid()
  69. {
  70. return isset($this->_nodes[$this->_current]);
  71. }
  72. /**
  73. * @return false|int
  74. *
  75. * @deprecated 102.0.0
  76. */
  77. public function next()
  78. {
  79. if ($this->_current > $this->_currentNode) {
  80. return false;
  81. } else {
  82. return $this->_current++;
  83. }
  84. }
  85. /**
  86. * @return int
  87. *
  88. * @deprecated 102.0.0
  89. */
  90. public function key()
  91. {
  92. return $this->_current;
  93. }
  94. /**
  95. * @return Node
  96. *
  97. * @deprecated 102.0.0
  98. */
  99. public function current()
  100. {
  101. return $this->_nodes[$this->_current];
  102. }
  103. /**
  104. * @return void
  105. *
  106. * @deprecated 102.0.0
  107. */
  108. public function rewind()
  109. {
  110. $this->_current = 0;
  111. }
  112. }