Source for file collector.php
Documentation is available at collector.php
* This file contains the following classes: {@link SimpleCollector},
* {@link SimplePatternCollector}.
* @author Travis Swicegood <development@domain51.com>
* @version $Id: collector.php 1723 2008-04-08 00:34:10Z lastcraft $
* The basic collector for {@link GroupTest}
* @see collect(), GroupTest::collect()
* Strips off any kind of slash at the end so as to normalise the path.
* @param string $path Path to normalise.
* @return string Path without trailing slash.
if (substr($path, -
1) ==
DIRECTORY_SEPARATOR) {
} elseif (substr($path, -
1) ==
'/') {
* Scans the directory and adds what it can.
* @param object $test Group test with {@link GroupTest::addTestFile()} method.
* @param string $path Directory to scan.
while (($entry =
readdir($handle)) !==
false) {
if ($this->_isHidden($entry)) {
$this->_handle($test, $path .
DIRECTORY_SEPARATOR .
$entry);
* This method determines what should be done with a given file and adds
* it via {@link GroupTest::addTestFile()} if necessary.
* This method should be overriden to provide custom matching criteria,
* such as pattern matching, recursive matching, etc. For an example, see
* {@link SimplePatternCollector::_handle()}.
* @param object $test Group test with {@link GroupTest::addTestFile()} method.
* @param string $filename A filename as generated by {@link collect()}
$test->addTestFile($file);
* Tests for hidden files so as to skip them. Currently
* only tests for Unix hidden files.
* @param string $filename Plain filename.
* @return boolean True if hidden file.
function _isHidden($filename) {
return strncmp($filename, '.', 1) ==
0;
* An extension to {@link SimpleCollector} that only adds files matching a
* @param string $pattern Perl compatible regex to test name against
* See {@link http://us4.php.net/manual/en/reference.pcre.pattern.syntax.php PHP's PCRE}
* for full documentation of valid pattern.s
* Attempts to add files that match a given pattern.
* @see SimpleCollector::_handle()
* @param object $test Group test with {@link GroupTest::addTestFile()} method.
* @param string $path Directory to scan.
function _handle(&$test, $filename) {
Documentation generated on Sun, 04 May 2008 09:21:21 -0500 by phpDocumentor 1.3.0