PHP code example of linko / spamfilter

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

    

linko / spamfilter example snippets


	


use SpamDetector\SpamDetector;

// Create a black list spam detector
$blackListDetector = new BlackList();

// add some text string to the black list detector
$blackListDetector->add('example.com');
$blackListDetector->add('127.0.0.1');

// Create the spam filter
$spamDetector = new SpamDetector();

// Register the spam detector
$spamDetector->registerDetector($blackListDetector);


// Run the check
$spamCheckResult = $spamDetector->check("
	Hello, this is some text containing example.com
	and should fail as it has a word that is black-listed
");

if($spamCheckResult->passed()) {
	// Do stuff
}


class LengthTooLong implements SpamDetectorInterface
{
	public function detect($string)
	{
		if (str_word_count($string) > 200) {
			return true;
		}

		return false;
	}
}

...

$lengthTooLong = new LengthTooLong();

$spamFilter->registerDetector($lengthTooLong);