public function files()
{
$files = Collection::make($this->disk->allFiles($this->path));
$filesByFile = $files->groupBy(function ($file) {
$fileName = $file->getBasename('.' . $file->getExtension());
if (Str::contains($file->getPath(), 'vendor')) {
$fileName = str_replace('.php', '', $file->getFileName());
$packageName = basename(dirname($file->getPath()));
return "{$packageName}::{$fileName}";
} else {
return $fileName;
}
})->map(function ($files) {
return $files->keyBy(function ($file) {
return basename($file->getPath());
})->map(function ($file) {
return $file->getRealPath();
});
});
// If the path does not contain "vendor" then we're looking at the
// main language files of the application, in this case we will
// neglect all vendor files.
if (!Str::contains($this->path, 'vendor')) {
$filesByFile = $this->neglectVendorFiles($filesByFile);
}
return $filesByFile;
}