PHP code example of omalie / kata-kotor

1. Go to this page and download the library: Download omalie/kata-kotor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

omalie / kata-kotor example snippets




return [
    /*
    |--------------------------------------------------------------------------
    | Default Language
    |--------------------------------------------------------------------------
    |
    | Bahasa default untuk memfilter kata kotor. Contoh: 'id' = Indonesia,
    | 'en' = English. Bisa di-override saat penggunaan.
    |
    */
    'default_language' => 'id',
];

use OmAlie\KataKotor\Facades\KataKotor;

class MessageController extends Controller
{
    public function sendMessage(Request $request)
    {
        $message = $request->input('message');

        if (KataKotor::hasBadwords($message)) {
            return response()->json([
                'error' => 'Message has bad word!'
            ], 400);
        }

        // Lanjut proses...
    }
}

$found = KataKotor::getBadwords($message);
// Hasil: ['bodoh', 'goblok']

$clean = KataKotor::censorText($message, '****');
// Semua kata kotor diganti dengan ****

// Deteksi dalam bahasa Inggris
$hasEn = KataKotor::hasBadwords($message, 'en');
bash
php artisan vendor:publish --tag=kata-kotor-config
text
kata-kotor/
├── composer.json
├── README.md
├── LICENSE
├── config/
│   └── kata-kotor.php
├── resources/
│   └── badwords/
│       ├── id.txt
│       └── en.txt
└── src/
    ├── Facades/
    │   └── KataKotor.php
    ├── KataKotor.php
    ├── KataKotorService.php
    └── KataKotorServiceProvider.php