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;
29 * @param \Iterator $iterator The Iterator to filter
30 * @param int $mode The mode (self::ONLY_FILES or self::ONLY_DIRECTORIES)
32 public function __construct(\Iterator $iterator, $mode)
36 parent::__construct($iterator);
40 * Filters the iterator values.
42 * @return bool true if the value should be kept, false otherwise
44 public function accept()
46 $fileinfo = $this->current();
47 if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
49 } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {