PHPackages                             linko/spamfilter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. linko/spamfilter

AbandonedArchivedLibrary

linko/spamfilter
================

An extensible simple spam detector library

0.2.0(9y ago)22213[2 issues](https://github.com/morrelinko/spamfilter/issues)MITPHPPHP &gt;=5.3.0

Since Jan 16Pushed 9y ago3 watchersCompare

[ Source](https://github.com/morrelinko/spamfilter)[ Packagist](https://packagist.org/packages/linko/spamfilter)[ RSS](/packages/linko-spamfilter/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Spam Detector
-------------

[](#spam-detector)

Spam Filter is a simple library for detecting spam messages. It follows the open closed principle by introducing Spam Detectors which are just separate classes used to extend the spam filter detecting capabilities.

[![Build Status](https://camo.githubusercontent.com/abdf65d5af1c3c031925b1202d95fb7da21dd3ba1436265886cae184d099ddc9/68747470733a2f2f7472617669732d63692e6f72672f6d6f7272656c696e6b6f2f7370616d2d6465746563746f722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/morrelinko/spam-detector)

Installation
------------

[](#installation)

Spam Filter library can be loaded into your projects using [Composer](http://getcomposer.org) or by loading the inbuilt autoloader.

##### Composer Installation

[](#composer-installation)

You can define the spam filter as a dependency in your project. Below is a minimal setup required

```
{
	"require" : {
		"morrelinko/spam-detector": "0.2.0"
	}
}
```

##### Using autoload.php

[](#using-autoloadphp)

If you are not using composer for your dependency (which you should) there is a simple autoloader packaged with this library which you can just 'include()' into your project files

```
	require_once '/path/to/spam-detector/autoload.php';
```

Setup
-----

[](#setup)

This should be done once throughout your app

```
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);
```

Usage
-----

[](#usage)

```
// 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
}
```

Each time you call the `check()` method on a string, it returns a `SpamResult`Object which holds the ... hmm ... spam check result.

You could provide more information about the entity trying to perform the action you are checking against the spam detector.

```
