public function File_Iterator_Facade::getFilesAsArray in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/phpunit/php-file-iterator/src/Facade.php \File_Iterator_Facade::getFilesAsArray()
Parameters
array|string $paths:
array|string $suffixes:
array|string $prefixes:
array $exclude:
bool $commonPath:
Return value
array
File
- vendor/
phpunit/ php-file-iterator/ src/ Facade.php, line 29
Class
- File_Iterator_Facade
- Façade implementation that uses File_Iterator_Factory to create a File_Iterator that operates on an AppendIterator that contains an RecursiveDirectoryIterator for each given path. The list of unique files is returned as an array.
Code
public function getFilesAsArray($paths, $suffixes = '', $prefixes = '', array $exclude = array(), $commonPath = FALSE) {
if (is_string($paths)) {
$paths = array(
$paths,
);
}
$factory = new File_Iterator_Factory();
$iterator = $factory
->getFileIterator($paths, $suffixes, $prefixes, $exclude);
$files = array();
foreach ($iterator as $file) {
$file = $file
->getRealPath();
if ($file) {
$files[] = $file;
}
}
foreach ($paths as $path) {
if (is_file($path)) {
$files[] = realpath($path);
}
}
$files = array_unique($files);
sort($files);
if ($commonPath) {
return array(
'commonPath' => $this
->getCommonPath($files),
'files' => $files,
);
}
else {
return $files;
}
}