You are here

class DepthRangeFilterIterator in Database Sanitize 7

DepthRangeFilterIterator limits the directory depth.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

Expanded class hierarchy of DepthRangeFilterIterator

2 files declare their use of DepthRangeFilterIterator
DepthRangeFilterIteratorTest.php in vendor/symfony/finder/Tests/Iterator/DepthRangeFilterIteratorTest.php
Finder.php in vendor/symfony/finder/Finder.php

File

vendor/symfony/finder/Iterator/DepthRangeFilterIterator.php, line 19

Namespace

Symfony\Component\Finder\Iterator
View source
class DepthRangeFilterIterator extends FilterIterator {
  private $minDepth = 0;

  /**
   * @param \RecursiveIteratorIterator $iterator The Iterator to filter
   * @param int                        $minDepth The min depth
   * @param int                        $maxDepth The max depth
   */
  public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX) {
    $this->minDepth = $minDepth;
    $iterator
      ->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
    parent::__construct($iterator);
  }

  /**
   * Filters the iterator values.
   *
   * @return bool true if the value should be kept, false otherwise
   */
  public function accept() {
    return $this
      ->getInnerIterator()
      ->getDepth() >= $this->minDepth;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DepthRangeFilterIterator::$minDepth private property
DepthRangeFilterIterator::accept public function Filters the iterator values.
DepthRangeFilterIterator::__construct public function
FilterIterator::rewind public function This is a workaround for the problem with \FilterIterator leaving inner \FilesystemIterator in wrong state after rewind in some cases. Overrides FilterIterator::rewind 1