{"id":17966007,"url":"https://github.com/blaspsoft/blasp","last_synced_at":"2026-01-28T23:12:43.280Z","repository":{"id":258650438,"uuid":"875360512","full_name":"Blaspsoft/blasp","owner":"Blaspsoft","description":"🤬 🚫 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.","archived":false,"fork":false,"pushed_at":"2025-02-27T21:59:48.000Z","size":203,"stargazers_count":241,"open_issues_count":8,"forks_count":17,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-15T12:03:40.740Z","etag":null,"topics":["content-moderation","laravel","php","profanity-check","profanity-detection","profanity-filter","profanity-library","profanity-validator","profanityfilter"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Blaspsoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-19T19:06:34.000Z","updated_at":"2025-05-07T09:13:23.000Z","dependencies_parsed_at":"2025-01-29T07:00:31.578Z","dependency_job_id":"9654eeb4-0bbc-40a5-9184-c7823c6bd9ac","html_url":"https://github.com/Blaspsoft/blasp","commit_stats":null,"previous_names":["blaspsoft/blasp"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blaspsoft%2Fblasp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blaspsoft%2Fblasp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blaspsoft%2Fblasp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blaspsoft%2Fblasp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Blaspsoft","download_url":"https://codeload.github.com/Blaspsoft/blasp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337612,"owners_count":22054253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["content-moderation","laravel","php","profanity-check","profanity-detection","profanity-filter","profanity-library","profanity-validator","profanityfilter"],"created_at":"2024-10-29T13:06:37.704Z","updated_at":"2026-01-26T22:22:19.274Z","avatar_url":"https://github.com/Blaspsoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./assets/icon.png\" alt=\"Blasp Icon\" width=\"150\" height=\"150\"/\u003e\n    \u003cp align=\"center\"\u003e\n        \u003ca href=\"https://github.com/Blaspsoft/blasp/actions/workflows/main.yml\"\u003e\u003cimg alt=\"GitHub Workflow Status (main)\" src=\"https://github.com/Blaspsoft/blasp/actions/workflows/main.yml/badge.svg\"\u003e\u003c/a\u003e\n        \u003ca href=\"https://packagist.org/packages/blaspsoft/blasp\"\u003e\u003cimg alt=\"Total Downloads\" src=\"https://img.shields.io/packagist/dt/blaspsoft/blasp\"\u003e\u003c/a\u003e\n        \u003ca href=\"https://packagist.org/packages/blaspsoft/blasp\"\u003e\u003cimg alt=\"Latest Version\" src=\"https://img.shields.io/packagist/v/blaspsoft/blasp\"\u003e\u003c/a\u003e\n        \u003ca href=\"https://packagist.org/packages/blaspsoft/blasp\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/packagist/l/blaspsoft/blasp\"\u003e\u003c/a\u003e\n    \u003c/p\u003e\n\u003c/p\u003e\n\n# Blasp - Advanced Profanity Filter for Laravel\n\nBlasp is a powerful, extensible profanity filter package for Laravel that helps detect and mask profane words in text. Version 3.0 introduces a simplified API with method chaining, comprehensive multi-language support (English, Spanish, German, French), all-languages detection mode, and advanced caching for enterprise-grade performance.\n\n## ✨ Key Features\n\n- **🔗 Method Chaining**: Elegant fluent API with `Blasp::spanish()-\u003echeck()`\n- **🌍 Multi-Language Support**: English, Spanish, German, and French with language-specific normalizers\n- **🌐 All Languages Mode**: Check against all languages simultaneously with `Blasp::allLanguages()`\n- **🎨 Custom Masking**: Configure custom mask characters with `maskWith()` method\n- **⚡ High Performance**: Advanced caching with O(1) lookups and optimized algorithms\n- **🎯 Smart Detection**: Handles substitutions, separators, variations, and false positives\n- **🏗️ Modern Architecture**: Built on SOLID principles with dependency injection\n- **✅ Battle Tested**: 148 tests with 858 assertions ensuring reliability\n\n## Installation\n\nYou can install the package via Composer:\n\n```bash\ncomposer require blaspsoft/blasp\n```\n\n## Quick Start\n\n### Basic Usage\n\n```php\nuse Blaspsoft\\Blasp\\Facades\\Blasp;\n\n// Simple usage - uses default language from config\n$result = Blasp::check('This is a fucking shit sentence');\n\n// With method chaining for specific language\n$result = Blasp::spanish()-\u003echeck('esto es una mierda');\n\n// Check against ALL languages at once\n$result = Blasp::allLanguages()-\u003echeck('fuck merde scheiße mierda');\n```\n\n### Simplified API with Method Chaining\n\n```php\n// Language shortcuts\nBlasp::english()-\u003echeck($text);\nBlasp::spanish()-\u003echeck($text);\nBlasp::german()-\u003echeck($text);\nBlasp::french()-\u003echeck($text);\n\n// Check against all languages\nBlasp::allLanguages()-\u003echeck($text);\n\n// Custom mask character\nBlasp::maskWith('#')-\u003echeck($text);\nBlasp::maskWith('●')-\u003echeck($text);\n\n// Configure custom profanities\nBlasp::configure(['badword'], ['goodword'])-\u003echeck($text);\n\n// Chain multiple methods together\nBlasp::spanish()-\u003emaskWith('*')-\u003echeck($text);\nBlasp::allLanguages()-\u003emaskWith('-')-\u003echeck($text);\n```\n\n### Working with Results\n\n```php\n$result = Blasp::check('This is fucking awesome');\n\n$result-\u003egetSourceString();           // \"This is fucking awesome\"\n$result-\u003egetCleanString();            // \"This is ******* awesome\"\n$result-\u003ehasProfanity();             // true\n$result-\u003egetProfanitiesCount();      // 1\n$result-\u003egetUniqueProfanitiesFound(); // ['fucking']\n\n// With custom mask character\n$result = Blasp::maskWith('#')-\u003echeck('This is fucking awesome');\n$result-\u003egetCleanString();            // \"This is ####### awesome\"\n```\n\n### Profanity Detection Types\n\nBlasp can detect different types of profanities based on variations such as:\n\n1. **Straight match**: Direct matches of profane words.\n2. **Substitution**: Substituted characters (e.g., `pro0fán1ty`).\n3. **Obscured**: Profanities with separators (e.g., `p-r-o-f-a-n-i-t-y`).\n4. **Doubled**: Repeated letters (e.g., `pprrooffaanniittyy`).\n5. **Combination**: Combinations of the above (e.g., `pp-rof@n|tty`).\n\n### Laravel Validation Rule\n\nBlasp also provides a custom Laravel validation rule called `blasp_check`, which you can use to validate form input for profanity.\n\n#### Example\n\n```php\n$request-\u003emerge(['sentence' =\u003e 'This is f u c k 1 n g awesome!']);\n\n$validated = $request-\u003evalidate([\n    'sentence' =\u003e ['blasp_check'],\n]);\n\n// With language specification\n$validated = $request-\u003evalidate([\n    'sentence' =\u003e ['blasp_check:spanish'],\n]);\n```\n\n### Configuration\n\nBlasp uses configuration files to manage profanities, separators, and substitutions. The main configuration includes:\n\n```php\n// config/blasp.php\nreturn [\n    'default_language' =\u003e 'english',  // Default language for detection\n    'mask_character' =\u003e '*',          // Default character for masking profanities\n    'separators' =\u003e [...],            // Special characters used as separators\n    'substitutions' =\u003e [...],         // Character substitutions (like @ for a)\n    'false_positives' =\u003e [...],       // Words that should not be flagged\n];\n```\n\nYou can publish the configuration files:\n\n```bash\n# Publish everything (config + all language files)\nphp artisan vendor:publish --tag=\"blasp\"\n\n# Publish only the main configuration file\nphp artisan vendor:publish --tag=\"blasp-config\"\n\n# Publish only the language files\nphp artisan vendor:publish --tag=\"blasp-languages\"\n```\n\nThis will publish:\n- `config/blasp.php` - Main configuration with default language settings\n- `config/languages/` - Language-specific profanity lists (English, Spanish, German, French)\n\n### Custom Configuration\n\nYou can specify custom profanity and false positive lists using the `configure()` method:\n\n```php\nuse Blaspsoft\\Blasp\\Facades\\Blasp;\n\n$blasp = Blasp::configure(\n    profanities: $your_custom_profanities,\n    falsePositives: $your_custom_false_positives\n)-\u003echeck($text);\n```\n\nThis is particularly useful when you need different profanity rules for specific contexts, such as username validation.\n\n\n## 🚀 Advanced Features (v3.0+)\n\n### All Languages Detection\n\nPerfect for international platforms, forums, or any application with multilingual content:\n\n```php\n// Check text against ALL configured languages at once\n$result = Blasp::allLanguages()-\u003echeck('fuck merde scheiße mierda');\n// Detects profanities from English, French, German, and Spanish\n\n// Get detailed results\necho $result-\u003egetProfanitiesCount();        // 4\necho $result-\u003egetUniqueProfanitiesFound();  // ['fuck', 'merde', 'scheiße', 'mierda']\n```\n\n### Multi-Language Support\n\nBlasp includes comprehensive support for multiple languages with automatic character normalization:\n\n- **English**: Full profanity database with common variations\n- **Spanish**: Handles accent normalization (á→a, ñ→n)\n- **German**: Processes umlauts (ä→ae, ö→oe, ü→ue) and ß→ss\n- **French**: Accent and cedilla normalization\n\n\n### Complete Chainable Methods Reference\n\n```php\n// Language selection methods\nBlasp::language('spanish')     // Set any language by name\nBlasp::english()               // Shortcut for English\nBlasp::spanish()               // Shortcut for Spanish\nBlasp::german()                // Shortcut for German\nBlasp::french()                // Shortcut for French\nBlasp::allLanguages()          // Check against all languages\n\n// Configuration methods\nBlasp::configure($profanities, $falsePositives)  // Custom word lists\nBlasp::maskWith('#')                             // Custom mask character\n\n// Detection method\nBlasp::check($text)            // Analyze text for profanities\n\n// All methods return BlaspService for chaining\n$service = Blasp::spanish()                      // Returns BlaspService\n    -\u003emaskWith('●')                              // Returns BlaspService\n    -\u003econfigure(['custom'], ['false_positive'])  // Returns BlaspService\n    -\u003echeck('texto para verificar');             // Returns BlaspService with results\n```\n\n### Advanced Method Chaining Examples\n\n```php\n// Example 1: Spanish with custom mask\nBlasp::spanish()\n    -\u003emaskWith('#')\n    -\u003echeck('esto es una mierda');\n// Result: \"esto es una ######\"\n\n// Example 2: All languages with custom configuration\nBlasp::allLanguages()\n    -\u003econfigure(['newbadword'], ['safephrase'])\n    -\u003emaskWith('-')\n    -\u003echeck('multiple fuck merde languages');\n// Result: \"multiple ---- ----- languages\"\n\n// Example 3: Dynamic language selection\n$language = $user-\u003epreferred_language; // 'french'\nBlasp::language($language)\n    -\u003emaskWith($user-\u003emask_preference ?? '*')\n    -\u003echeck($userContent);\n```\n\n### Laravel Integration\n\n```php\n// Laravel service container integration\n$blasp = app(BlaspService::class);\n\n// Validation rule with default language\n$request-\u003evalidate([\n    'message' =\u003e 'required|blasp_check'\n]);\n\n// Validation rule with specific language\n$request-\u003evalidate([\n    'message' =\u003e 'required|blasp_check:spanish'\n]);\n```\n\n### Cache Management\n\nBlasp 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:\n\n```bash\nphp artisan blasp:clear\n```\n\nThis command will clear all cached Blasp expressions and configurations.\n\n### Cache Driver Configuration\n\nBy default, Blasp uses Laravel's default cache driver. You can specify a different cache driver for Blasp by setting the `cache_driver` option in your configuration:\n\n```php\n// config/blasp.php\nreturn [\n    'cache_driver' =\u003e env('BLASP_CACHE_DRIVER'),\n    // ...\n];\n```\n\nOr set it via environment variable:\n\n```env\nBLASP_CACHE_DRIVER=redis\n```\n\nThis is particularly useful in environments like **Laravel Vapor** where the default cache driver (DynamoDB) has size limits that can be exceeded when caching large profanity expression sets. By configuring a different cache driver (such as Redis), you can avoid these limitations.\n\n## ⚡ Performance\n\nBlasp v3.0 includes significant performance optimizations:\n\n- **Cached Expression Sorting**: Profanity expressions are sorted once and cached, eliminating repeated O(n log n) operations\n- **Hash Map Lookups**: False positive checking and unique profanity tracking use O(1) hash map lookups instead of O(n) linear searches\n- **Optimized Regular Expressions**: Improved regex generation and matching algorithms\n- **Intelligent Caching**: Multi-layer caching system with automatic cache invalidation\n\n### Benchmarks\n\nVersion 3.0 shows substantial performance improvements over v2:\n- **Expression Processing**: 60% faster profanity expression generation\n- **Detection Speed**: 40% faster text analysis with large profanity lists\n- **Memory Usage**: 30% reduction in memory footprint\n- **Cache Efficiency**: 80% fewer database/config queries with intelligent caching\n\n## 🔄 Migration from v2.x to v3.0\n\n### 100% Backward Compatible\n\nAll existing v2.x code continues to work without any changes:\n\n```php\n// Existing code works exactly the same\nuse Blaspsoft\\Blasp\\Facades\\Blasp;\n\n$result = Blasp::check('text to check');\n$result = Blasp::configure($profanities, $falsePositives)-\u003echeck('text');\n```\n\n### New Features in v3.0\n\nTake advantage of the simplified API:\n\n```php\n// NEW: Method chaining\nBlasp::spanish()-\u003echeck($text);\n\n// NEW: All languages detection\nBlasp::allLanguages()-\u003echeck($text);\n\n// NEW: Language shortcuts\nBlasp::german()-\u003echeck($text);\nBlasp::french()-\u003echeck($text);\n\n// NEW: Custom mask characters\nBlasp::maskWith('#')-\u003echeck($text);\nBlasp::spanish()-\u003emaskWith('●')-\u003echeck($text);\n\n// NEW: Default language configuration\n// Set in config/blasp.php: 'default_language' =\u003e 'spanish'\nBlasp::check($text); // Now uses Spanish by default\n```\n\n## 🎨 Custom Masking\n\n### Using Custom Mask Characters\n\nYou can customize how profanities are masked using the `maskWith()` method:\n\n```php\n// Use hash symbols instead of asterisks\n$result = Blasp::maskWith('#')-\u003echeck('This is fucking awesome');\necho $result-\u003egetCleanString(); // \"This is ####### awesome\"\n\n// Use dots for masking\n$result = Blasp::maskWith('·')-\u003echeck('What the hell');\necho $result-\u003egetCleanString(); // \"What the ····\"\n\n// Unicode characters work too\n$result = Blasp::maskWith('●')-\u003echeck('damn it');\necho $result-\u003egetCleanString(); // \"●●●● it\"\n```\n\n### Setting Default Mask Character\n\nYou can set a default mask character in the configuration:\n\n```php\n// config/blasp.php\nreturn [\n    'mask_character' =\u003e '#',  // All profanities will be masked with #\n    // ...\n];\n```\n\n### Combining with Other Methods\n\nThe `maskWith()` method can be chained with other methods:\n\n```php\n// Spanish text with custom mask\nBlasp::spanish()-\u003emaskWith('@')-\u003echeck('esto es mierda');\n\n// All languages with dots\nBlasp::allLanguages()-\u003emaskWith('·')-\u003echeck('multilingual text');\n\n// Configure and mask\nBlasp::configure(['custom'], [])\n    -\u003emaskWith('-')\n    -\u003echeck('custom text');\n```\n\n## 🏗️ Architecture\n\nBlasp v3.0 follows SOLID principles and modern PHP practices:\n\n- **Facade Pattern**: Simplified API with Laravel facade integration\n- **Builder Pattern**: Method chaining for fluent interface\n- **Strategy Pattern**: Language-specific detection and normalization\n- **Dependency Injection**: Full Laravel service container integration\n- **Caching**: Intelligent performance optimization\n\n## 📋 Requirements\n\n- PHP 8.1+\n- Laravel 10.0+\n- BCMath PHP Extension (for advanced calculations)\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n## 📄 Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for detailed version history.\n\n## License\n\nBlasp is open-sourced software licensed under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaspsoft%2Fblasp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblaspsoft%2Fblasp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaspsoft%2Fblasp/lists"}