PHPackages                             crudleapps/profanity - 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. crudleapps/profanity

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

crudleapps/profanity
====================

Profanity filter package for PHP

v1.0.1(9y ago)21.8kMITPHP

Since Jul 22Pushed 9y ago2 watchersCompare

[ Source](https://github.com/CrudleApps/profanity)[ Packagist](https://packagist.org/packages/crudleapps/profanity)[ RSS](/packages/crudleapps-profanity/feed)WikiDiscussions master Synced 4w ago

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

Profanity - A PHP Profanity Filter
==================================

[](#profanity---a-php-profanity-filter)

It's important to note that, while this was fun to put together, profanity filters will likely never work the way we all need them to. Profanity relies almost entirely on context; for example, "bitch" can easily refer to a female dog. "Dick" could refer to Richard.

However, there are some words that are bad no matter the context. This package tries to remedy the situations where you need to safe guard against naughty words (e.g. in forums where young children frequent)

Installation
============

[](#installation)

There are no other dependencies for this package so run the below and you're good to go.

```
composer require crudleapps/profanity

```

Usage
=====

[](#usage)

The filter requires at least one `Dictionary` to function. This package comes with a GB and US dictionary out of the box.

```
use Crudle\Profanity\Filter;
use Crudle\Profanity\Dictionary\GB;

$filter = new Filter(new GB);

// Clean a string
$filter->cleanse('Joe is a little bitch'); // Returns 'Joe is a little *****'

// Clean a string with a custom censor character
$filter->cleanse('Joe is a little bitch', 'x'); // Returns 'Joe is a little xxxxx'

// Check if a string is dirty
$filter->isDirty('Joe is a little bitch'); // Returns true
```

Dictionaries
============

[](#dictionaries)

It is entirely possible that the dictionaries included in this package are either too strict or not strict enough for your use. That's no problem. You can easily create your own dictionary by extending `Crudle\Profanity\Dictionary\AbstractDictionary`

All you need to include is a protected `$badWords` member with your array of words. For example:

```
class MyDictionary extends AbstractDictionary
{
    protected $badWords = [
        'bollocks',
        'twat'
    ];
}

$filter = new Filter(new MyDictionary);
```

There is another way if you dislike extending someone elses code. You can simply pass your own array of words to any dictionaries `add` method.

```
$dictionary = new GB();
$dictionary->add(['dicks', 'bitches']);

// Alternatively, clear the existing words in the dictionary if you want to start fresh
$dictionary->clear();
$dictionary->add(['ho', 'testicle']);
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Every ~0 days

Total

2

Last Release

3630d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20602309?v=4)[crudle-apps](/maintainers/crudle-apps)[@crudle-apps](https://github.com/crudle-apps)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/crudleapps-profanity/health.svg)

```
[![Health](https://phpackages.com/badges/crudleapps-profanity/health.svg)](https://phpackages.com/packages/crudleapps-profanity)
```

###  Alternatives

[netojose/laravel-bootstrap-4-forms

Bootstrap 4 form builder for Laravel 5

180119.8k](/packages/netojose-laravel-bootstrap-4-forms)[michalsn/minifier

Assets minification and versioning library for CodeIgniter 4.

5437.5k](/packages/michalsn-minifier)[qeq66/think-jump

101.1k](/packages/qeq66-think-jump)

PHPackages © 2026

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