Download the PHP package blaspsoft/blasp without Composer
On this page you can find all versions of the php package blaspsoft/blasp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download blaspsoft/blasp
More information about blaspsoft/blasp
Files in blaspsoft/blasp
Package blasp
Short Description Blasp is a powerful and customisable profanity filter package for Laravel applications
License MIT
Homepage https://github.com/blaspsoft/blasp
Informations about the package blasp
Blasp - Profanity Filter for Laravel
Blasp is a profanity filter package for Laravel that helps detect and mask profane words in a given sentence. It offers a robust set of features for handling variations of offensive language, including substitutions, obscured characters, and doubled letters.
Installation
You can install the package via Composer:
Usage
Basic Usage
To use the profanity filter, simply call the Blasp::check()
method with the sentence you want to check for profanity.
The returned object will contain the following properties:
- sourceString: The original string you passed.
- cleanString: The string with profanities masked (e.g., replaced with
*
). - hasProfanity: A boolean indicating whether the string contains profanity.
- profanitiesCount: The number of profanities found.
- uniqueProfanitiesFound: An array of unique profanities found in the string.
Example
Profanity Detection Types
Blasp can detect different types of profanities based on variations such as:
- Straight match: Direct matches of profane words.
- Substitution: Substituted characters (e.g.,
pro0fán1ty
). - Obscured: Profanities with separators (e.g.,
p-r-o-f-a-n-i-t-y
). - Doubled: Repeated letters (e.g.,
pprrooffaanniittyy
). - Combination: Combinations of the above (e.g.,
pp-rof@n|tty
).
Laravel Validation Rule
Blasp also provides a custom Laravel validation rule called blasp_check
, which you can use to validate form input for profanity.
Example
Configuration
Blasp uses a configuration file (config/blasp.php
) to manage the list of profanities, separators, and substitutions. You can publish the configuration file using the following Artisan command:
Custom Configuration
You can specify custom profanity and false positive lists using the configure()
method:
This is particularly useful when you need different profanity rules for specific contexts, such as username validation.
Cache Management
Blasp uses Laravel's cache system to improve performance. The package automatically caches profanity expressions and their variations. To clear the cache, you can use the provided Artisan command:
This command will clear all cached Blasp expressions and configurations.
License
Blasp is open-sourced software licensed under the MIT license.