Refactor readFiles method to improve .txt file filtering logic

This commit is contained in:
dhanabalan
2025-09-26 10:26:04 +05:30
parent f50fbf5771
commit 8a3c0639ad

View File

@@ -58,9 +58,14 @@ class SapFileController extends Controller
}
// Filter only .txt files
$files = array_filter($allFiles, function($file) use ($path) {
return $file !== '.' && $file !== '..' && is_file($path . $file)
&& pathinfo($file, PATHINFO_EXTENSION) === 'txt';
// $files = array_filter($allFiles, function($file) use ($path) {
// return $file !== '.' && $file !== '..' && is_file($path . $file)
// && pathinfo($file, PATHINFO_EXTENSION) === 'txt';
// });
$files = array_filter($allFiles, function($item) use ($path) {
$fullPath = $path . '/' . $item;
return @is_file($fullPath) && pathinfo($item, PATHINFO_EXTENSION) === 'txt';
});