File tree 1 file changed +19
-17
lines changed
1 file changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public static function get(): LazyCollection
16
16
$ baseDir = dirname ($ path );
17
17
18
18
return static ::getLines ($ path )->map (function ($ line ) use ($ baseDir ) {
19
- return static ::parseLine ($ baseDir , trim ( $ line) );
19
+ return static ::parseLine ($ baseDir ,$ line );
20
20
})->flatten ()->filter ();
21
21
}
22
22
@@ -37,22 +37,24 @@ protected static function getLines($path): LazyCollection
37
37
});
38
38
}
39
39
40
- protected static function parseLine ($ baseDir , $ line ): false | array | null
40
+ protected static function parseLine ($ baseDir , $ line ): array
41
41
{
42
- $ line = trim ($ line );
43
-
44
- return Arr::map (match ($ line ) {
45
- '' , '# ' => [], // ignore empty lines and comments
46
- default => glob ("$ baseDir/ $ line " )
47
- }, static function ($ line ) use ($ baseDir ) {
48
- return Str::of ($ line )
49
- ->after ($ baseDir )
50
- ->trim ('/ ' )
51
- ->pipe (function ($ line ) {
52
- return '/^ ' .preg_quote ($ line , '/ ' ).'/ ' ;
53
- })
54
- ->toString ();
55
- });
42
+ switch (trim ($ line )) {
43
+ // ignore empty lines and comments
44
+ case '' :
45
+ case '# ' :
46
+ return [];
47
+ default :
48
+ return Arr::map (glob ($ baseDir .'/ ' .trim ($ line , '/ ' )), function ($ path ) use ($ baseDir ) {
49
+ return Str::of ($ path )
50
+ ->after ($ baseDir )
51
+ ->trim ('/ ' )
52
+ ->pipe (function ($ line ) {
53
+ return '/^ ' .preg_quote ($ line , '/ ' ).'/ ' ;
54
+ })
55
+ ->toString ();
56
+ });
57
+ }
58
+
56
59
}
57
60
}
58
-
You can’t perform that action at this time.
0 commit comments