class SizeRangeFilterIterator in Database Sanitize 7
SizeRangeFilterIterator filters out files that are not in the given size range.
@author Fabien Potencier <fabien@symfony.com>
Hierarchy
- class \Symfony\Component\Finder\Iterator\FilterIterator
- class \Symfony\Component\Finder\Iterator\FilterIterator
- class \Symfony\Component\Finder\Iterator\SizeRangeFilterIterator
- class \Symfony\Component\Finder\Iterator\FilterIterator
Expanded class hierarchy of SizeRangeFilterIterator
2 files declare their use of SizeRangeFilterIterator
- Finder.php in vendor/
symfony/ finder/ Finder.php - SizeRangeFilterIteratorTest.php in vendor/
symfony/ finder/ Tests/ Iterator/ SizeRangeFilterIteratorTest.php
File
- vendor/
symfony/ finder/ Iterator/ SizeRangeFilterIterator.php, line 21
Namespace
Symfony\Component\Finder\IteratorView source
class SizeRangeFilterIterator extends FilterIterator {
private $comparators = array();
/**
* @param \Iterator $iterator The Iterator to filter
* @param NumberComparator[] $comparators An array of NumberComparator instances
*/
public function __construct(\Iterator $iterator, array $comparators) {
$this->comparators = $comparators;
parent::__construct($iterator);
}
/**
* Filters the iterator values.
*
* @return bool true if the value should be kept, false otherwise
*/
public function accept() {
$fileinfo = $this
->current();
if (!$fileinfo
->isFile()) {
return true;
}
$filesize = $fileinfo
->getSize();
foreach ($this->comparators as $compare) {
if (!$compare
->test($filesize)) {
return false;
}
}
return true;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FilterIterator:: |
public | function |
This is a workaround for the problem with \FilterIterator leaving inner \FilesystemIterator in wrong state after
rewind in some cases. Overrides FilterIterator:: |
1 |
SizeRangeFilterIterator:: |
private | property | ||
SizeRangeFilterIterator:: |
public | function | Filters the iterator values. | |
SizeRangeFilterIterator:: |
public | function |