Iterator.php 983 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Symfony\Tests\Components\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. {
  19. $this->attach(new \SplFileInfo($value));
  20. }
  21. $this->rewind();
  22. }
  23. public function attach(\SplFileInfo $fileinfo)
  24. {
  25. $this->values[] = $fileinfo;
  26. }
  27. public function rewind()
  28. {
  29. reset($this->values);
  30. }
  31. public function valid()
  32. {
  33. return false !== $this->current();
  34. }
  35. public function next()
  36. {
  37. next($this->values);
  38. }
  39. public function current()
  40. {
  41. return current($this->values);
  42. }
  43. public function key()
  44. {
  45. return key($this->values);
  46. }
  47. }