TYPO3  7.6
PathFilterIterator.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Symfony\Component\Finder\Iterator;
13 
21 {
27  public function accept()
28  {
29  $filename = $this->current()->getRelativePathname();
30 
31  if ('\\' === DIRECTORY_SEPARATOR) {
32  $filename = str_replace('\\', '/', $filename);
33  }
34 
35  // should at least not match one rule to exclude
36  foreach ($this->noMatchRegexps as $regex) {
37  if (preg_match($regex, $filename)) {
38  return false;
39  }
40  }
41 
42  // should at least match one rule
43  $match = true;
44  if ($this->matchRegexps) {
45  $match = false;
46  foreach ($this->matchRegexps as $regex) {
47  if (preg_match($regex, $filename)) {
48  return true;
49  }
50  }
51  }
52 
53  return $match;
54  }
55 
70  protected function toRegex($str)
71  {
72  return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
73  }
74 }