Download the PHP package szymanski-luk/polish-profanity-filter without Composer
On this page you can find all versions of the php package szymanski-luk/polish-profanity-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download szymanski-luk/polish-profanity-filter
More information about szymanski-luk/polish-profanity-filter
Files in szymanski-luk/polish-profanity-filter
Package polish-profanity-filter
Short Description Polish profanity filter with support for inflections, masking and detection
License MIT
Informations about the package polish-profanity-filter
Polish Profanity Filter 🇵🇱
Lightweight PHP library for detecting and masking Polish profanity in text.
Supports:
- case-insensitive detection
- Unicode-safe matching
- configurable masking strategies
- custom dictionary providers
- custom search patterns
- match position detection (start/end offsets)
Designed for moderation systems, comments filtering, validation pipelines, and content sanitization.
Requirements
- PHP 8.1
- ext-mbstring
Installation
Basic usage
Checking if text contains profanity
Finding matches with offsets
Example result:
findProfanities() returns a MatchCollection object. Available methods:
isEmpty(): boolall(): arrayfirst(): ?MatchResultlast(): ?MatchResultcount(): intcontainsWord(string $word, bool $caseInsensitive = true): bool
Masking profanity
Extending
This package can be extended with custom maskers, additional dictionary providers, and custom search patterns.
Custom Masker
To create a custom Masker, create a class that implements the MaskerInterface.
Example:
Now you should instantiate PolishProfanityFilter as follows:
Additional Dictionary
To create an additional Dictionary, create a class that implements the DictionaryProviderInterface.
Now you should instantiate PolishProfanityFilter as follows:
...or you can override default Dictionary:
Custom SearchPattern
To create a custom SearchPattern, create a class that implements the SearchPatternInterface.
Now you should instantiate PolishProfanityFilter as follows:
Advanced Usage
If you use Symfony and want to register PolishProfanityFilter as a service, you can do it like this:
or (in case you want to extend filter)
Contributing
Contributions are welcome.
You can help by:
- improving the default dictionary
- improving search patterns
- fixing bugs
- adding tests and documentation
Please open an issue or submit a pull request.
Development
Run tests:
Run static analysis:
Run code style:
Fix code style:
License
MIT
All versions of polish-profanity-filter with dependencies
ext-mbstring Version *