SearchResultIterator.php 956 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Ui\Model\Export;
  7. class SearchResultIterator implements \Iterator
  8. {
  9. /**
  10. * @var array
  11. */
  12. protected $items;
  13. /**
  14. * @param array $items
  15. */
  16. public function __construct(
  17. array $items
  18. ) {
  19. $this->items = $items;
  20. }
  21. /**
  22. * @return array|mixed
  23. */
  24. public function current()
  25. {
  26. return current($this->items);
  27. }
  28. /**
  29. * @return int|mixed
  30. */
  31. public function key()
  32. {
  33. return key($this->items);
  34. }
  35. /**
  36. * @return void
  37. */
  38. public function next()
  39. {
  40. next($this->items);
  41. }
  42. /**
  43. * @return void
  44. */
  45. public function rewind()
  46. {
  47. reset($this->items);
  48. }
  49. /**
  50. * @return bool
  51. */
  52. public function valid()
  53. {
  54. return $this->key() !== null;
  55. }
  56. }