13
13
use DragonCode \LaravelActions \Repositories \ActionRepository ;
14
14
use DragonCode \LaravelActions \Services \Migrator ;
15
15
use DragonCode \LaravelActions \Values \Options ;
16
+ use DragonCode \Support \Facades \Helpers \Arr ;
16
17
use DragonCode \Support \Facades \Helpers \Str ;
17
18
use DragonCode \Support \Filesystem \File ;
18
19
use Illuminate \Console \OutputStyle ;
@@ -47,13 +48,11 @@ protected function getFiles(string $path, ?Closure $filter = null): array
47
48
{
48
49
$ file = Str::finish ($ path , '.php ' );
49
50
50
- if ($ this ->file ->exists ($ file ) && $ this ->file ->isFile ($ file )) {
51
- return [$ file ];
52
- }
51
+ $ files = $ this ->isFile ($ file ) ? [$ file ] : $ this ->file ->names ($ path , $ filter , true );
53
52
54
- return $ this ->sorter ->byValues (
55
- $ this -> file -> names ( $ path , $ filter , true )
56
- );
53
+ return Arr:: of ( $ this ->sorter ->byValues ($ files ))
54
+ -> map ( fn ( string $ value ) => Str:: before ( $ value , ' .php ' ) )
55
+ -> toArray ( );
57
56
}
58
57
59
58
protected function runCommand (string $ command , array $ options = []): void
@@ -76,4 +75,9 @@ protected function fireEvent(string $event, string $method): void
76
75
{
77
76
$ this ->events ->dispatch (new $ event ($ method , $ this ->options ->before ));
78
77
}
78
+
79
+ protected function isFile (string $ path ): bool
80
+ {
81
+ return $ this ->file ->exists ($ path ) && $ this ->file ->isFile ($ path );
82
+ }
79
83
}
0 commit comments