aklump / gitignore
Small library for matching gitignore style (glob) patterns.
0.0.3
2024-02-16 23:18 UTC
Requires
- php: >=7.3
Requires (Dev)
- aklump/phpswap: ^0.0.7
- phpunit/phpunit: ^9.5
README
A small library to allow you to work with .gitignore (glob) patterns.
Test a .gitignore pattern
$pattern = new \AKlump\GitIgnore\Pattern('foo/**/*.php'); $pattern->matches('foo/bar/baz/lorem.php') === TRUE;
Convert to RegEx
$pattern = new \AKlump\GitIgnore\Pattern('settings*.php'); $pattern->toRegex() === '#^settings[^/]*\.php/?$#';
Check If String Contains a Pattern
\AKlump\GitIgnore\Analyzer::containsPattern('foo/**') === TRUE \AKlump\GitIgnore\Analyzer::containsPattern('foo/bar') === FALSE
Known Issues
Not all special characters are yet supported.