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\Glob;
17 * FilenameFilterIterator filters files by patterns (a regexp, a glob, or a string).
19 * @author Fabien Potencier <fabien@symfony.com>
21 class FilenameFilterIterator extends MultiplePcreFilterIterator
24 * Filters the iterator values.
26 * @return bool true if the value should be kept, false otherwise
28 public function accept()
30 return $this->isAccepted($this->current()->getFilename());
34 * Converts glob to regexp.
36 * PCRE patterns are left unchanged.
37 * Glob strings are transformed with Glob::toRegex().
39 * @param string $str Pattern: glob or regexp
41 * @return string regexp corresponding to a given glob or regexp
43 protected function toRegex($str)
45 return $this->isRegex($str) ? $str : Glob::toRegex($str);