You are here

protected function xautoload_RegistryWildcard_RecursiveScan::_validCand in X Autoload 7.2

1 call to xautoload_RegistryWildcard_RecursiveScan::_validCand()
xautoload_RegistryWildcard_RecursiveScan::_abc in lib/RegistryWildcard/RecursiveScan.php

File

lib/RegistryWildcard/RecursiveScan.php, line 57

Class

xautoload_RegistryWildcard_RecursiveScan
Scan directories for wildcard files[] instructions in a module's info file.

Code

protected function _validCand($candidate, $b) {
  if ($candidate == '.' || $candidate == '..') {
    return FALSE;
  }
  if (strpos($candidate, '*') !== FALSE) {
    return FALSE;
  }
  if ($b == '*' || $b == '**') {
    return TRUE;
  }

  // More complex wildcard string.
  $fragments = array();
  foreach (explode('*', $b) as $fragment) {
    $fragments[] = preg_quote($fragment);
  }
  $regex = implode('.*', $fragments);
  return preg_match("/^{$regex}\$/", $candidate);
}