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\Tests\Component\Finder\Iterator;
  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. }