Iterator.php 1.0 KB

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