Download the PHP package faresmts/safewords without Composer
On this page you can find all versions of the php package faresmts/safewords. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download faresmts/safewords
More information about faresmts/safewords
Files in faresmts/safewords
Package safewords
Short Description a PHP lib for filtering bad words from strings
License MIT
Informations about the package safewords
filter bad words from your php string
Safewords is a package that can be used in any PHP framework, calling in a static method and returning the censored text or a boolean to know if is safe.
Support me staring this repository or connecting with me in linkedin
Installation
You can install the package via composer:
Usage
This is the simplest way to call a safewords checker:
And this is the way to call a safewords censor:
Both methods can be called with useDictionary() function to add new words to block:
Functions
-
filter(string $text)
: add the text you want to check. -
useDictionary(array $userBadWords)
: add the words you want to block in SafeWords checker. -
isSafe()
: method that evaluates whether the text is safe. -
replace(string $replace = '*')
: method that replaces each character of the bad word with the variable inside $string. Default is '*'. get()
: get the result of the chosen method.
Exceptions
-
The methods
isSafe()
andreplace()
cannot be called at the same time, throwing an exception if this happens. - The method
useDictionary()
cannot be called after theisSafe()
orreplace()
. It must be called before.