v4.0.0
Blasp v4.0.0
A ground-up rewrite with a driver-based architecture, severity scoring, and deep Laravel integration.
New Features
- Driver-based architecture β
regex(obfuscation/substitution detection),pattern(fast exact matching),phonetic(sound-alike evasion via metaphone + Levenshtein), andpipeline(chain multiple drivers together). Extend with custom drivers. - Severity scoring β Profanities categorised as mild/moderate/high/extreme with per-word weights and a 0β100 composite score. Filter by minimum severity threshold.
- Multi-language support β English, Spanish, German, French with language-specific normalizers and severity maps. Check one, many, or all at once via fluent API.
- Masking strategies β Character mask (
*,#), grawlix (!@#$%), or a custom callback. - Eloquent integration β
Blaspabletrait auto-sanitizes or rejects profanity on model save, withwithoutBlaspChecking()for bypassing. - Middleware β
CheckProfanitymiddleware to reject or sanitize profane request fields with configurable severity and field filtering. - Validation rule β
blasp_checkrule with language support. - Blade directive β
@clean($text)for output sanitization. - Str/Stringable macros β
Str::isProfane(),Str::cleanProfanity(), and Stringable equivalents. - Result caching β Configurable cache driver, TTL, and key eviction.
- Events β
ProfanityDetected,ContentBlocked,ModelProfanityDetected. - Testing utilities β
Blasp::fake()for test doubles with assertions.
Breaking Changes
- Namespace flattened β
Blaspsoft\Blasp\Laravel\merged intoBlaspsoft\Blasp\. Update any direct class references. - Service provider renamed β
ServiceProviderβBlaspServiceProvider(auto-discovery handles this). - Config file renamed β
config/config.phpβconfig/blasp.php. Re-publish withphp artisan vendor:publish --tag="blasp-config". - API changes β
check()now returns aResultobject withisOffensive(),clean(),score(),severity(),count(),words(),uniqueWords(). Previous methods likehasProfanity(),getCleanString(),getProfanitiesCount()are removed.
Compatibility
- PHP 8.2+
- Laravel 8.0 β 13.x