### Install Blasp Package via Composer Source: https://github.com/blaspsoft/blasp/blob/main/README.md This command installs the Blasp package using Composer, a dependency manager for PHP. Ensure Composer is installed and accessible in your terminal. ```bash composer require blaspsoft/blasp ``` -------------------------------- ### Advanced Chaining Examples Source: https://github.com/blaspsoft/blasp/blob/main/README.md Demonstrates advanced usage of Blasp's chainable methods, including combining language selection, custom masking, and custom configurations for various scenarios. ```PHP // Example 1: Spanish with custom mask Blasp::spanish() ->maskWith('#') ->check('esto es una mierda'); // Example 2: All languages with custom configuration Blasp::allLanguages() ->configure(['newbadword'], ['safephrase']) ->maskWith('-') ->check('multiple fuck merde languages'); // Example 3: Dynamic language selection $language = $user->preferred_language; Blasp::language($language) ->maskWith($user->mask_preference ?? '*') ->check($userContent); ``` -------------------------------- ### Blasp Custom Masking Example Source: https://github.com/blaspsoft/blasp/blob/main/README.md Shows how to use the `maskWith()` method to specify a custom character for masking profanities. The `getCleanString()` method on the result object will then reflect the custom mask. ```php $result = Blasp::maskWith('#')->check('This is fucking awesome'); $result->getCleanString(); // "This is ####### awesome" ``` -------------------------------- ### PHP Custom Masking with maskWith() Source: https://github.com/blaspsoft/blasp/blob/main/README.md Shows how to customize profanity masking in Blasp v3.0 using the `maskWith()` method. Examples include using different characters like '#' and '·', and even Unicode characters for masking. ```PHP // Use hash symbols instead of asterisks $result = Blasp::maskWith('#')->check('This is fucking awesome'); echo $result->getCleanString(); // "This is ####### awesome" // Use dots for masking $result = Blasp::maskWith('·')->check('What the hell'); echo $result->getCleanString(); // "What the ····" // Unicode characters work too $result = Blasp::maskWith('●')->check('damn it'); echo $result->getCleanString(); // "●●●● it" ``` -------------------------------- ### Publishing Configuration Files Source: https://github.com/blaspsoft/blasp/blob/main/README.md Artisan commands to publish Blasp's configuration and language files to your Laravel project. This makes the configuration files accessible for modification. ```Bash php artisan vendor:publish --tag="blasp" php artisan vendor:publish --tag="blasp-config" php artisan vendor:publish --tag="blasp-languages" ``` -------------------------------- ### PHP New Features: Method Chaining and Language Support Source: https://github.com/blaspsoft/blasp/blob/main/README.md Illustrates new features in Blasp v3.0, including method chaining for a fluent API, detecting all languages, and using language-specific shortcuts. It also shows how to set default languages. ```PHP // NEW: Method chaining Blasp::spanish()->check($text); // NEW: All languages detection Blasp::allLanguages()->check($text); // NEW: Language shortcuts Blasp::german()->check($text); Blasp::french()->check($text); // NEW: Default language configuration // Set in config/blasp.php: 'default_language' => 'spanish' Blasp::check($text); // Now uses Spanish by default ``` -------------------------------- ### Configuration and Detection Methods Source: https://github.com/blaspsoft/blasp/blob/main/README.md Details methods for custom configuration, setting mask characters, and performing the actual text check. All these methods are chainable. ```PHP Blasp::configure($profanities, $falsePositives) Blasp::maskWith('#') Blasp::check($text) ``` -------------------------------- ### PHP Backward Compatibility Source: https://github.com/blaspsoft/blasp/blob/main/README.md Demonstrates that existing v2.x code for the Blasp library continues to function without modifications in v3.0. It shows basic usage of the Blasp facade for checking text and configuring profanities. ```PHP use Blaspsoft\Blasp\Facades\Blasp; $result = Blasp::check('text to check'); $result = Blasp::configure($profanities, $falsePositives)->check('text'); ``` -------------------------------- ### Language Selection Methods Source: https://github.com/blaspsoft/blasp/blob/main/README.md Provides methods to select specific languages or all languages for profanity checking. Includes shortcuts for common languages and a method for dynamic language selection. ```PHP Blasp::language('spanish') Blasp::english() Blasp::spanish() Blasp::german() Blasp::french() Blasp::allLanguages() ``` -------------------------------- ### Blasp Method Chaining for Language and Masking Source: https://github.com/blaspsoft/blasp/blob/main/README.md Illustrates the fluent API of Blasp, allowing method chaining for specifying languages, custom mask characters, and configuring profanities. This enables a more readable and flexible way to use the profanity filter. ```php // Language shortcuts Blasp::english()->check($text); Blasp::spanish()->check($text); Blasp::german()->check($text); Blasp::french()->check($text); // Check against all languages Blasp::allLanguages()->check($text); // Custom mask character Blasp::maskWith('#')->check($text); Blasp::maskWith('●')->check($text); // Configure custom profanities Blasp::configure(['badword'], ['goodword'])->check($text); // Chain multiple methods together Blasp::spanish()->maskWith('*')->check($text); Blasp::allLanguages()->maskWith('-')->check($text); ``` -------------------------------- ### PHP Configuration Source: https://github.com/blaspsoft/blasp/blob/main/README.md Defines the default configuration for the Blasp package, including masking characters, separators, substitutions, and false positives. This file is typically located at `config/blasp.php`. ```PHP return [ 'default_language' => 'english', 'mask_character' => '*', 'separators' => [...], 'substitutions' => [...], 'false_positives' => [...], ]; ``` -------------------------------- ### Custom Configuration with `configure()` Source: https://github.com/blaspsoft/blasp/blob/main/README.md Allows overriding default profanity and false positive lists using the `configure()` method. This is useful for context-specific filtering, such as username validation. ```PHP use Blaspsoft\Blasp\Facades\Blasp; $blasp = Blasp::configure( profanities: $your_custom_profanities, falsePositives: $your_custom_false_positives )->check($text); ``` -------------------------------- ### PHP Chaining maskWith() with Other Methods Source: https://github.com/blaspsoft/blasp/blob/main/README.md Demonstrates the flexibility of Blasp v3.0 by chaining the `maskWith()` method with other functionalities like language selection and configuration. This allows for combined customization of text analysis. ```PHP // Spanish text with custom mask Blasp::spanish()->maskWith('@')->check('esto es mierda'); // All languages with dots Blasp::allLanguages()->maskWith('·')->check('multilingual text'); // Configure and mask Blasp::configure(['custom'], []) ->maskWith('-') ->check('custom text'); ``` -------------------------------- ### Basic Blasp Profanity Check Source: https://github.com/blaspsoft/blasp/blob/main/README.md Demonstrates the basic usage of the Blasp facade to check a sentence for profanity. It uses the default language configured in the application. The result object contains methods to retrieve the original string, cleaned string, and profanity details. ```php use Blaspsoft\Blasp\Facades\Blasp; // Simple usage - uses default language from config $result = Blasp::check('This is a fucking shit sentence'); // Check against ALL languages at once $result = Blasp::allLanguages()->check('fuck merde scheiße mierda'); $result->getSourceString(); // "This is a fucking shit sentence" $result->getCleanString(); // "This is ******* shit sentence" $result->hasProfanity(); // true $result->getProfanitiesCount(); // 2 $result->getUniqueProfanitiesFound(); // ['fucking', 'shit'] ``` -------------------------------- ### Laravel Integration and Validation Source: https://github.com/blaspsoft/blasp/blob/main/README.md Shows how to integrate Blasp with Laravel's service container and use it as a validation rule for incoming request data. Supports default and specific language validation. ```PHP $blasp = app(BlaspService::class); $request->validate([ 'message' => 'required|blasp_check' ]); $request->validate([ 'message' => 'required|blasp_check:spanish' ]); ``` -------------------------------- ### Clearing Blasp Cache Source: https://github.com/blaspsoft/blasp/blob/main/README.md An Artisan command to clear Blasp's cached profanity expressions and configurations, ensuring that any changes to the configuration or language files are reflected. ```Bash php artisan blasp:clear ``` -------------------------------- ### All Languages Detection Source: https://github.com/blaspsoft/blasp/blob/main/README.md Checks text against all configured languages simultaneously. This is ideal for international platforms needing to detect profanities across multiple languages. ```PHP $result = Blasp::allLanguages()->check('fuck merde scheiße mierda'); echo $result->getProfanitiesCount(); echo $result->getUniqueProfanitiesFound(); ``` -------------------------------- ### Blasp Laravel Validation Rule Source: https://github.com/blaspsoft/blasp/blob/main/README.md Demonstrates how to use the custom `blasp_check` validation rule provided by the Blasp package in Laravel. This rule can be applied to form input to automatically check for profanity, with an option to specify a language. ```php $request->merge(['sentence' => 'This is f u c k 1 n g awesome!']); $validated = $request->validate([ 'sentence' => ['blasp_check'], ]); // With language specification $validated = $request->validate([ 'sentence' => ['blasp_check:spanish'], ]); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.