You are here

private function Finder::searchInDirectory in Database Sanitize 7

Parameters

string $dir:

Return value

\Iterator

1 call to Finder::searchInDirectory()
Finder::getIterator in vendor/symfony/finder/Finder.php
Returns an Iterator for the current Finder configuration.

File

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

Class

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

Namespace

Symfony\Component\Finder

Code

private function searchInDirectory($dir) {
  if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
    $this->exclude = array_merge($this->exclude, self::$vcsPatterns);
  }
  if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
    $this->notPaths[] = '#(^|/)\\..+(/|$)#';
  }
  $minDepth = 0;
  $maxDepth = PHP_INT_MAX;
  foreach ($this->depths as $comparator) {
    switch ($comparator
      ->getOperator()) {
      case '>':
        $minDepth = $comparator
          ->getTarget() + 1;
        break;
      case '>=':
        $minDepth = $comparator
          ->getTarget();
        break;
      case '<':
        $maxDepth = $comparator
          ->getTarget() - 1;
        break;
      case '<=':
        $maxDepth = $comparator
          ->getTarget();
        break;
      default:
        $minDepth = $maxDepth = $comparator
          ->getTarget();
    }
  }
  $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  if ($this->followLinks) {
    $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  }
  $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  if ($this->exclude) {
    $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  }
  $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) {
    $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  }
  if ($this->mode) {
    $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  }
  if ($this->names || $this->notNames) {
    $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  }
  if ($this->contains || $this->notContains) {
    $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  }
  if ($this->sizes) {
    $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  }
  if ($this->dates) {
    $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  }
  if ($this->filters) {
    $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  }
  if ($this->paths || $this->notPaths) {
    $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  }
  if ($this->sort) {
    $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
    $iterator = $iteratorAggregate
      ->getIterator();
  }
  return $iterator;
}