PHP code example of divineomega / is_offensive

1. Go to this page and download the library: Download divineomega/is_offensive 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/ */

    

divineomega / is_offensive example snippets


is_offensive('fuck');  // true
is_offensive('fuk');   // true

is_offensive('duck');  // false
is_offensive('cat');   // false

is_offensive('sex');         // true
is_offensive('Middlesex');   // false

is_offensive('tit');         // true
is_offensive('Tittesworth'); // false

is_offensive('cunt');        // true
is_offensive('Scunthorpe');  // false

$offensive = (new OffensiveChecker())->isOffensive('fuck')  // true

$blacklist = ['moist', 'stinky', 'poo'];

$offensiveChecker = new OffensiveChecker($blacklist);

$offensiveChecker->isOffensive('poo');     // true
$offensiveChecker->isOffensive('poops');   // true

$blacklist = ['moist', 'stinky', 'poo'];
$whitelist = ['poop'];

$offensiveChecker = new OffensiveChecker($blacklist, $whitelist);

$offensiveChecker->isOffensive('poo');     // true
$offensiveChecker->isOffensive('poops');   // false