Iterator.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Symfony\Tests\Component\Finder\Iterator;
  3. /*
  4. * This file is part of the Symfony framework.
  5. *
  6. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. class Iterator implements \Iterator
  12. {
  13. protected $values;
  14. public function __construct(array $values = array())
  15. {
  16. $this->values = array();
  17. foreach ($values as $value) {
  18. $this->attach(new \SplFileInfo($value));
  19. }
  20. $this->rewind();
  21. }
  22. public function attach(\SplFileInfo $fileinfo)
  23. {
  24. $this->values[] = $fileinfo;
  25. }
  26. public function rewind()
  27. {
  28. reset($this->values);
  29. }
  30. public function valid()
  31. {
  32. return false !== $this->current();
  33. }
  34. public function next()
  35. {
  36. next($this->values);
  37. }
  38. public function current()
  39. {
  40. return current($this->values);
  41. }
  42. public function key()
  43. {
  44. return key($this->values);
  45. }
  46. }