Iterator.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 = array();
  14. public function __construct(array $values = array())
  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. }