PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/drush/composer/vendor/symfony/finder/Iterator/FilenameFilterIterator.php

https://bitbucket.org/kbasarab/kbasarab_vim
PHP | 47 lines | 14 code | 5 blank | 28 comment | 0 complexity | 80b06fadc52136ca0a93567f33b0ebf7 MD5 | raw file
Possible License(s): MIT
  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($str)
  39. {
  40. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  41. }
  42. }