@@ -117,9 +117,9 @@ Blasp uses configuration files to manage profanities, separators, and substituti
117117// config/blasp.php
118118return [
119119 'default_language' => 'english', // Default language for detection
120- 'merge_domain_strategies' => true, // Include all domain strategies by default
121120 'separators' => [...], // Special characters used as separators
122121 'substitutions' => [...], // Character substitutions (like @ for a)
122+ 'false_positives' => [...], // Words that should not be flagged
123123];
124124```
125125
@@ -137,12 +137,8 @@ php artisan vendor:publish --tag="blasp-languages"
137137```
138138
139139This will publish:
140- - ` config/blasp.php ` - Main configuration with default language, separators, and substitutions
141- - ` config/languages/ ` - Language-specific profanity lists:
142- - ` english.php ` - English profanities and false positives
143- - ` spanish.php ` - Spanish profanities and false positives
144- - ` german.php ` - German profanities and false positives
145- - ` french.php ` - French profanities and false positives
140+ - ` config/blasp.php ` - Main configuration with default language settings
141+ - ` config/languages/ ` - Language-specific profanity lists (English, Spanish, German, French)
146142
147143### Custom Configuration
148144
@@ -159,22 +155,6 @@ $blasp = Blasp::configure(
159155
160156This is particularly useful when you need different profanity rules for specific contexts, such as username validation.
161157
162- ### Language-Specific Detection
163-
164- ``` php
165- // Using the facade with method chaining (recommended)
166- $result = Blasp::spanish()->check('texto con palabras malas');
167- $result = Blasp::german()->check('text mit schlechten Wörtern');
168- $result = Blasp::french()->check('texte avec des gros mots');
169-
170- // Check against ALL languages simultaneously
171- $result = Blasp::allLanguages()->check('multilingual text with bad words in any language');
172-
173- // Using the service directly
174- use Blaspsoft\Blasp\BlaspService;
175- $service = new BlaspService();
176- $result = $service->language('spanish')->check('texto con palabras malas');
177- ```
178158
179159## 🚀 Advanced Features (v3.0+)
180160
@@ -198,47 +178,13 @@ echo $result->getUniqueProfanitiesFound(); // ['fuck', 'merde', 'scheiße', 'mi
198178
199179### Multi-Language Support
200180
201- Blasp includes comprehensive multi-language support with language-specific character normalization:
181+ Blasp includes comprehensive support for multiple languages with automatic character normalization:
202182
203- #### Built-in Languages
204183- ** English** : Full profanity database with common variations
205- - ** Spanish** : Includes accent normalization (á→a) , ñ→n, ll→y, rr→r transformations
206- - ** German** : Handles umlauts (ä→ae, ö→oe, ü→ue), ß→ss, sch→sh transformations
184+ - ** Spanish** : Handles accent normalization (á→a, ñ→n)
185+ - ** German** : Processes umlauts (ä→ae, ö→oe, ü→ue) and ß→ss
207186- ** French** : Accent and cedilla normalization
208187
209- #### Simple Language Switching
210-
211- ``` php
212- // Quick language switching with facade
213- Blasp::english()->check($text);
214- Blasp::spanish()->check($text);
215- Blasp::german()->check($text);
216- Blasp::french()->check($text);
217-
218- // Dynamic language selection
219- $language = $request->get('language', 'english');
220- Blasp::language($language)->check($text);
221-
222- // Check all languages at once
223- Blasp::allLanguages()->check($text);
224- ```
225-
226- #### Language-Specific Normalizers
227-
228- Each language has its own normalizer to handle character variations:
229-
230- ``` php
231- use Blaspsoft\Blasp\Normalizers\SpanishStringNormalizer;
232- use Blaspsoft\Blasp\Normalizers\GermanStringNormalizer;
233-
234- // Spanish normalizer handles accents and special characters
235- $spanishNormalizer = new SpanishStringNormalizer();
236- $normalized = $spanishNormalizer->normalize('niño'); // Returns: 'nino'
237-
238- // German normalizer handles umlauts and compound letters
239- $germanNormalizer = new GermanStringNormalizer();
240- $normalized = $germanNormalizer->normalize('schöne'); // Returns: 'shoene'
241- ```
242188
243189### Method Chaining API
244190
@@ -261,25 +207,21 @@ Blasp::allLanguages()->lenient()->check($text);
261207Blasp::french()->configure($profanities)->check($text);
262208```
263209
264- ### Advanced Configuration
210+ ### Laravel Integration
265211
266- #### Dependency Injection
267212``` php
268- // Inject custom components
269- use Blaspsoft\Blasp\BlaspService;
270- use Blaspsoft\Blasp\Config\ConfigurationLoader;
271-
272- $customLoader = new ConfigurationLoader($customExpressionGenerator);
273- $blasp = new BlaspService(null, null, $customLoader);
274- ```
275-
276- #### Service Container Integration
277- ``` php
278- // Laravel service container automatically resolves dependencies
213+ // Laravel service container integration
279214$blasp = app(BlaspService::class);
280215
281- // Or bind custom implementations
282- app()->bind(ExpressionGeneratorInterface::class, CustomExpressionGenerator::class);
216+ // Validation rule with default language
217+ $request->validate([
218+ 'message' => 'required|blasp_check'
219+ ]);
220+
221+ // Validation rule with specific language
222+ $request->validate([
223+ 'message' => 'required|blasp_check:spanish'
224+ ]);
283225```
284226
285227### Cache Management
@@ -341,23 +283,17 @@ Blasp::french()->check($text);
341283// NEW: Default language configuration
342284// Set in config/blasp.php: 'default_language' => 'spanish'
343285Blasp::check($text); // Now uses Spanish by default
344-
345- // NEW: Cleaner API - no need for strategy factories
346- // Old way: StrategyFactory::createForContext(['domain' => 'gaming'])
347- // New way: Just use Blasp::check() - domain strategies merged by default
348286```
349287
350288## 🏗️ Architecture
351289
352290Blasp v3.0 follows SOLID principles and modern PHP practices:
353291
354- - ** Strategy Pattern** : Pluggable detection strategies for different contexts
355- - ** Factory Pattern** : Strategy creation and management
356- - ** Dependency Injection** : Full Laravel service container integration
357- - ** Registry Pattern** : Centralized strategy and normalizer management
358- - ** Observer Pattern** : Plugin system for extensibility
359- - ** Repository Pattern** : Configuration loading and caching
360- - ** Template Method Pattern** : Language-specific normalizers extending base functionality
292+ - ** Facade Pattern** : Simplified API with Laravel facade integration
293+ - ** Builder Pattern** : Method chaining for fluent interface
294+ - ** Strategy Pattern** : Language-specific detection and normalization
295+ - ** Dependency Injection** : Full Laravel service container integration
296+ - ** Caching** : Intelligent performance optimization
361297
362298## 📋 Requirements
363299
0 commit comments