vendor/symfony/finder/Iterator/FilenameFilterIterator.php line 28

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Finder\Iterator;
  11. use Symfony\Component\Finder\Glob;
  12. /**
  13.  * FilenameFilterIterator filters files by patterns (a regexp, a glob, or a string).
  14.  *
  15.  * @author Fabien Potencier <fabien@symfony.com>
  16.  */
  17. class FilenameFilterIterator extends MultiplePcreFilterIterator
  18. {
  19.     /**
  20.      * Filters the iterator values.
  21.      *
  22.      * @return bool true if the value should be kept, false otherwise
  23.      */
  24.     public function accept()
  25.     {
  26.         return $this->isAccepted($this->current()->getFilename());
  27.     }
  28.     /**
  29.      * Converts glob to regexp.
  30.      *
  31.      * PCRE patterns are left unchanged.
  32.      * Glob strings are transformed with Glob::toRegex().
  33.      *
  34.      * @param string $str Pattern: glob or regexp
  35.      *
  36.      * @return string regexp corresponding to a given glob or regexp
  37.      */
  38.     protected function toRegex(string $str)
  39.     {
  40.         return $this->isRegex($str) ? $str Glob::toRegex($str);
  41.     }
  42. }