IteratorSourceIterator.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Exporter\Source;
  11. /**
  12. * SourceIterator implementation based on Iterator
  13. */
  14. class IteratorSourceIterator implements SourceIteratorInterface
  15. {
  16. protected $iterator;
  17. /**
  18. * @param \Iterator $iterator Iterator with string array elements
  19. */
  20. public function __construct(\Iterator $iterator)
  21. {
  22. $this->iterator = $iterator;
  23. }
  24. /**
  25. * @return \Iterator
  26. */
  27. public function getIterator()
  28. {
  29. return $this->iterator;
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function current()
  35. {
  36. return $this->iterator->current();
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function next()
  42. {
  43. $this->iterator->next();
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function key()
  49. {
  50. return $this->iterator->key();
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function valid()
  56. {
  57. return $this->iterator->valid();
  58. }
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public function rewind()
  63. {
  64. $this->iterator->rewind();
  65. }
  66. }