Package Data | |
---|---|
Maintainer Username: | linkthrow |
Maintainer Contact: | hussan@uselinkthrow.com (Hussan Choudhry) |
Package Create Date: | 2016-02-29 |
Package Last Update: | 2016-02-29 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-14 15:05:34 |
Package Statistics | |
---|---|
Total Downloads: | 111 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Profanity Filter takes strings as input and removes any bad curse words that the string might have. It check the string for specific blacklist which must match as a sperate word to be considered as a curse word. If a curse word is found, then it will replace the curse word with a censor character the user chooses (default is *).
Default curse words from Shuttershock list of banned words https://github.com/shutterstock/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words
This package is intended to used with Laravel. Tested and working with laravel 5.1.
This code is based on Fastwebmedia/Profanity-Filter. A major part of it is taken from there and I added the things that I thought it required.
Via Composer
$ composer require LinkThrow/profanityfilter
###Laravel
Add LinkThrow\ProfanityFilter\ProfanityFilterServiceProvider::class
to your providers array.
If you wish to use the Facade then add
'Profanity' => LinkThrow\ProfanityFilter\Facades\Profanity::class
The package will automatically use the config file containing the list of banned words.
$swear_word = ['dog'];
$blacklist = ['puppy'];
$replace = ['a' => '(a|a\.|a\-|4|@|Á|á|À|Â|à|Â|â|Ä|ä|Ã|ã|Å|å|α|Δ|Λ|λ)'];
$profanity_filter = new LinkThrow\ProfanityFilter($swear_words, $blacklist, $replace);
echo $profanity_filter->clean('Dog, puppy badpuppy baddog!', '$');
The above code would return:
array(
'old_string' => 'Dog, puppy badpuppy baddog!',
'new_string' => '$$$, $$$$$ badpuppy bad$$$!',
'clean' => false
);
Please see CHANGELOG for more information what has changed recently.
$ phpspec run
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email LinkThrow.shakya@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.