4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Finder\Iterator;
14 use Symfony\Component\Finder\Comparator\DateComparator;
17 * DateRangeFilterIterator filters out files that are not in the given date range (last modified dates).
19 * @author Fabien Potencier <fabien@symfony.com>
21 class DateRangeFilterIterator extends FilterIterator
23 private $comparators = array();
28 * @param \Iterator $iterator The Iterator to filter
29 * @param DateComparator[] $comparators An array of DateComparator instances
31 public function __construct(\Iterator $iterator, array $comparators)
33 $this->comparators = $comparators;
35 parent::__construct($iterator);
39 * Filters the iterator values.
41 * @return bool true if the value should be kept, false otherwise
43 public function accept()
45 $fileinfo = $this->current();
47 if (!file_exists($fileinfo->getPathname())) {
51 $filedate = $fileinfo->getMTime();
52 foreach ($this->comparators as $compare) {
53 if (!$compare->test($filedate)) {