Skip to content

Commit 8cdb7b4

Browse files
committed
read me + publish lang
1 parent 253c299 commit 8cdb7b4

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

README.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Laravel 5 Profanity Filter
2-
Filter profanity, or other words, out of a string using Laravels [localization](https://laravel.com/docs/5.3/localization) feature.
1+
# Laravel 5 & PHP Profanity Filter
2+
Filter profanity, or other words, out of a string using Laravels [localization](https://laravel.com/docs/5.3/localization) feature or with any PHP application and some custom coding.
33

44
# Installation
55
```
@@ -11,12 +11,7 @@ Register the service providers to enable the package:
1111
Askedio\Laravel5ProfanityFilter\Providers\ProfanityFilterServiceProvider::class,
1212
```
1313

14-
Autoload it:
15-
```
16-
composer dumpautoload
17-
```
18-
19-
# Configure
14+
## Configure
2015
```
2116
php artisan vendor:publish
2217
```
@@ -38,5 +33,37 @@ You can also define things inline
3833
$string = app('profanityFilter')->replaceWith('#')->replaceFullWords(false)->filter('something with a bad word'));
3934
```
4035

36+
# Options
37+
* `filter($string = string, $details = boolean)` pass a string to be filtered.
38+
39+
* Enable details to have an array of results returned:
40+
```php
41+
[
42+
"orig" => "",
43+
"clean" => "",
44+
"hasMatch" => boolean,
45+
"matched" => []
46+
]
47+
```
48+
* `reset()` reset `replaceWith` and `replaceFullWords` to defaults.
49+
* `replaceWith(string)` change the chars used to replace filtered strings.
50+
* `replaceFullWords(boolean)` enable to replace full words, disable to replace partial.
51+
52+
53+
# Profanity Filter with PHP
54+
You can also use this package without Laravel.
55+
56+
```php
57+
use Askedio\Laravel5ProfanityFilter\ProfanityFilter;
58+
59+
$config = []; // Data from `resources/config/profanity.php`
60+
$badWordsArray = []; // Data from `resources/lang/[lang]/profanity.php`
61+
62+
$profanityFilter = new ProfanityFilter($config, $badWordsArray);
63+
$string = $profanityFilter->filter('something with a bad word');
64+
```
65+
66+
67+
4168
# Credits
4269
This package is based on [banbuilder](https://github.com/snipe/banbuilder).

app/Providers/ProfanityFilterServiceProvider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public function boot()
3030
{
3131
$this->loadTranslationsFrom(realpath(__DIR__.'/../../resources/lang'), 'Laravel5ProfanityFilter');
3232

33-
$this->publishes([realpath(__DIR__.'/../../resources/config/profanity.php') => config_path('profanity.php')], 'config');
33+
$this->publishes([
34+
realpath(__DIR__.'/../../resources/config/profanity.php') => config_path('profanity.php'),
35+
realpath(__DIR__.'/../../resources/lang') => resource_path('lang/vendor/profanity'),
36+
], 'config');
3437
}
3538
}

0 commit comments

Comments
 (0)