Skip to content

Commit 05c4066

Browse files
committed
Replace match with switch to support older PHP versions
1 parent 3f3901e commit 05c4066

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/VaporIgnore.php

+19-17
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static function get(): LazyCollection
1616
$baseDir = dirname($path);
1717

1818
return static::getLines($path)->map(function ($line) use ($baseDir) {
19-
return static::parseLine($baseDir, trim($line));
19+
return static::parseLine($baseDir,$line);
2020
})->flatten()->filter();
2121
}
2222

@@ -37,22 +37,24 @@ protected static function getLines($path): LazyCollection
3737
});
3838
}
3939

40-
protected static function parseLine($baseDir, $line): false|array|null
40+
protected static function parseLine($baseDir, $line): array
4141
{
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+
5659
}
5760
}
58-

0 commit comments

Comments
 (0)