Skip to content

Commit

Permalink
Cleanup the code
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 15, 2024
1 parent 5e5a1d9 commit b3ab4e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 1 addition & 3 deletions packages/framework/src/Foundation/Kernel/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ public function smartGlob(string $pattern, int $flags = 0): Collection
/** @return \Illuminate\Support\Collection<int, string> */
public function findFiles(string $directory, string|array|false $matchExtensions = false, bool $recursive = false): Collection
{
$finder = app(FileFinder::class);

return $finder::handle($directory, $matchExtensions, $recursive);
return app(FileFinder::class)->handle($directory, $matchExtensions, $recursive);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class FileFinder
{
/**
* @param string|array<string>|false $matchExtensions
* @param string|array<string>|false $matchExtensions
* @return \Illuminate\Support\Collection<int, string>
*/
public static function handle(string $directory, string|array|false $matchExtensions = false, bool $recursive = false): Collection
Expand All @@ -36,8 +36,8 @@ public static function handle(string $directory, string|array|false $matchExtens
}

$finder->name('/\.('.implode('|', array_map(function (string $extension): string {
return preg_quote(ltrim($extension, '.'), '/');
}, $matchExtensions)).')$/i');
return preg_quote(ltrim($extension, '.'), '/');
}, $matchExtensions)).')$/i');
}

return collect($finder)->map(function (string $file): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ public function testFindFilesFromFilesystemFacadeWithArguments()
public function testCanSwapOutFileFinder()
{
app()->bind(FileFinder::class, function () {
return new class {
return new class
{
public static function handle(): Collection
{
return collect(['mocked']);
Expand Down

0 comments on commit b3ab4e1

Please sign in to comment.