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;
15 * FileTypeFilterIterator only keeps files, directories, or both.
17 * @author Fabien Potencier <fabien@symfony.com>
19 class FileTypeFilterIterator extends FilterIterator
22 const ONLY_DIRECTORIES = 2;
27 * @param \Iterator $iterator The Iterator to filter
28 * @param int $mode The mode (self::ONLY_FILES or self::ONLY_DIRECTORIES)
30 public function __construct(\Iterator $iterator, $mode)
34 parent::__construct($iterator);
38 * Filters the iterator values.
40 * @return bool true if the value should be kept, false otherwise
42 public function accept()
44 $fileinfo = $this->current();
45 if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
47 } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {