PHPackages                             flexic/spam-filter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. flexic/spam-filter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

flexic/spam-filter
==================

A PHP Spam-Filter

1.0.0(3y ago)23GPL-3.0-or-laterPHPPHP ^7.4

Since Oct 9Pushed 3y ago2 watchersCompare

[ Source](https://github.com/flexicsystems/spam-filter)[ Packagist](https://packagist.org/packages/flexic/spam-filter)[ Docs](https://www.themepoint.de)[ RSS](/packages/flexic-spam-filter/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Spam Filter
===========

[](#spam-filter)

The Spam-Filter package defines an object-oriented layer for checking strings about spam.

Build-in Filter Types
---------------------

[](#build-in-filter-types)

### Regex Filter

[](#regex-filter)

The Regex Filter is build to match Spam by an array of Regex patterns. If a regex pattern result matches the input will rate as spam.

### Blacklist Filter

[](#blacklist-filter)

The Blacklist Filter is used to match Spam by an array of patterns. If the input contain a pattern it will rate as spam .

### Whitelist Filter

[](#whitelist-filter)

The Whitelist Filter is build to check if the input contains any whitelisted patterns. If no whitelisted pattern contained the input will rate as spam.

### Url Filter

[](#url-filter)

The URL Filter is build to match if the input contains url's.

### Duplication Filter

[](#duplication-filter)

The Duplication Filter is build to match word duplications in text's. The `$minConsecutiveWords` defines if only words or sentences with a specific length will be matched. Warning: For larger text this filter performs a lot of operations.

Example
-------

[](#example)

```
$spamFilter = new \Flexic\SpamFilter\SpamFilter([
    new \Flexic\SpamFilter\Filter\BlacklistFilter([
        'want to buy'
    ]),
    new \Flexic\SpamFilter\Filter\RegexFilter([
        '/\[\[url\=.*\]\]/'
    ])
]);

$spamFilter->check(
    'Hello, how are you? Do you want to buy [[url=https://example.com/product]] this Product?'
); // Result: true (both filters detected spam)

$spamFilter->check(
    'Hey my friend. Do you want to test a new PHP Library?'
); // Result: false (No filter detected spam)
```

Create custom filter
--------------------

[](#create-custom-filter)

The Spam-Filter supports the creation of custom filters. The Custom-Filters must implement the `\ThemePoint\SpamFilter\Filter\FilterInterface` with it's defined functions.

Example:

```
class EmailFilter implements \Flexic\SpamFilter\Filter\FilterInterface
{
    public function check($input): bool
    {
        \preg_match_all('/(([^ ].*)@(.*))/', $input, $matches, \PREG_SET_ORDER, 0);

        if (\count($matches) > 0) {
            return true;
        }

        return false;
    }
}
```

Pay attention to the following behavior of the `check` function:

- Return `true` if spam is detected in input.
- Return `false` if no spam is detected in input.

Exceptions
----------

[](#exceptions)

You can control how the Spam Filter react if an exception is thrown. The value of `$responseOnException` is equivalent to the filter results.

If you want that the Spam Filter defines an input as Spam if an exception is thrown set this value to `true`.

Changelog
---------

[](#changelog)

\[1.0\]

- Initial commit of package

---

[![Donate](https://camo.githubusercontent.com/b57c445af971e3e99c2d0ccdbf4fa7faa4358ba27fecc8f68459b30289f82eda/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d626c75652e737667)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q98R2QXXMTUF6&source=url)

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1364d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bee461f8192dd9177138458bcf9558257c572316ca6fed26b68d2f1e7efbb5be?d=identicon)[ThemePoint](/maintainers/ThemePoint)

---

Top Contributors

[![ThemePoint](https://avatars.githubusercontent.com/u/28843201?v=4)](https://github.com/ThemePoint "ThemePoint (12 commits)")

### Embed Badge

![Health badge](/badges/flexic-spam-filter/health.svg)

```
[![Health](https://phpackages.com/badges/flexic-spam-filter/health.svg)](https://phpackages.com/packages/flexic-spam-filter)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
