You are here

public function Finder::getIterator in Database Sanitize 7

Returns an Iterator for the current Finder configuration.

This method implements the IteratorAggregate interface.

Return value

\Iterator|SplFileInfo[] An iterator

Throws

\LogicException if the in() method has not been called

2 calls to Finder::getIterator()
Finder::count in vendor/symfony/finder/Finder.php
Counts all the results collected by the iterators.
Finder::hasResults in vendor/symfony/finder/Finder.php
Check if the any results were found.

File

vendor/symfony/finder/Finder.php, line 565

Class

Finder
Finder allows to build rules to find files and directories.

Namespace

Symfony\Component\Finder

Code

public function getIterator() {
  if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
    throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  }
  if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
    return $this
      ->searchInDirectory($this->dirs[0]);
  }
  $iterator = new \AppendIterator();
  foreach ($this->dirs as $dir) {
    $iterator
      ->append($this
      ->searchInDirectory($dir));
  }
  foreach ($this->iterators as $it) {
    $iterator
      ->append($it);
  }
  return $iterator;
}