34 lines
941 B
PHP
34 lines
941 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Support\Architecture;
|
|
|
|
use RecursiveDirectoryIterator;
|
|
use RecursiveIteratorIterator;
|
|
|
|
final class ArchitectureFileFinder
|
|
{
|
|
/** @return string[] */
|
|
public function phpFiles(array $paths): array
|
|
{
|
|
$files = [];
|
|
foreach ($paths as $path) {
|
|
$absolute = base_path($path);
|
|
if (is_file($absolute) && str_ends_with($absolute, '.php')) {
|
|
$files[] = $absolute;
|
|
continue;
|
|
}
|
|
if (! is_dir($absolute)) {
|
|
continue;
|
|
}
|
|
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($absolute)) as $file) {
|
|
if ($file->isFile() && $file->getExtension() === 'php') {
|
|
$files[] = $file->getPathname();
|
|
}
|
|
}
|
|
}
|
|
|
|
sort($files);
|
|
return array_values(array_unique($files));
|
|
}
|
|
}
|