/** * Retrieves the instance of the Singleton. */ public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new SelectorUtils(); } return self::$instance; }
/** * Matches a string against a pattern. The pattern contains two special * characters: * '*' which means zero or more characters, * '?' which means one and only one character. * * @param string $pattern pattern to match against * @param string $str string that must be matched against the * pattern * @param bool $isCaseSensitive * * @return boolean true when the string matches against the pattern, * false otherwise. */ public function match($pattern, $str, $isCaseSensitive = true) { return SelectorUtils::match($pattern, $str, $isCaseSensitive); }
/** * The heart of the matter. This is where the selector gets to decide * on the inclusion of a file in a particular fileset. Most of the work * for this selector is offloaded into SelectorUtils, a static class * that provides the same services for both FilenameSelector and * DirectoryScanner. * * @param basedir the base directory the scan is being done from * @param filename is the name of the file to check * @param file is a PhingFile object the selector can use * @return whether the file should be selected or not */ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) { $this->validate(); return (SelectorUtils::matchPath($this->pattern, $filename, $this->casesensitive) === !($this->negated)); }
/** * The heart of the matter. This is where the selector gets to decide * on the inclusion of a file in a particular fileset. * * @param basedir the base directory the scan is being done from * @param filename is the name of the file to check * @param file is a PhingFile object the selector can use * @return whether the file should be selected or not */ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) { $this->validate(); // Determine file whose out-of-dateness is to be checked $destfiles = $this->map->main($filename); // If filename does not match the To attribute of the mapper // then filter it out of the files we are considering if ($destfiles === null) { return false; } // Sanity check if (count($destfiles) !== 1 || $destfiles[0] === null) { throw new BuildException("Invalid destination file results for " . $this->targetdir . " with filename " . $filename); } $destname = $destfiles[0]; $destfile = new PhingFile($this->targetdir, $destname); return SelectorUtils::isOutOfDate($file, $destfile, $this->granularity); }