public function shouldIgnoreFile($path, $basedir)
{
$relativePath = $path;
if (strpos($path, $basedir) === 0) {
// The +1 cuts off the directory separator as well.
$relativePath = substr($path, strlen($basedir) + 1);
}
foreach ($this->ignorePatterns as $pattern => $type) {
if (is_array($type) === true) {
// A sniff specific ignore pattern.
continue;
}
// Maintains backwards compatibility in case the ignore pattern does
// not have a relative/absolute value.
if (is_int($pattern) === true) {
$pattern = $type;
$type = 'absolute';
}
$replacements = array('\\,' => ',', '*' => '.*');
// We assume a / directory separator, as do the exclude rules
// most developers write, so we need a special case for any system
// that is different.
if (DIRECTORY_SEPARATOR === '\\') {
$replacements['/'] = '\\\\';
}
$pattern = strtr($pattern, $replacements);
if ($type === 'relative') {
$testPath = $relativePath;
} else {
$testPath = $path;
}
$pattern = '`' . $pattern . '`i';
if (preg_match($pattern, $testPath) === 1) {
return true;
}
}
//end foreach
return false;
}