aklump / gitignore
Small library for matching gitignore style (glob) patterns.
Installs: 201
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/aklump/gitignore
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.