PHPackages                             oliveris/bad-words - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. oliveris/bad-words

ActivePackage[Validation &amp; Sanitization](/categories/validation)

oliveris/bad-words
==================

Filters through text and cleans the input of bad words found.

v1.0.3(7y ago)1984MITPHP

Since May 1Pushed 7y ago1 watchersCompare

[ Source](https://github.com/oliveris/bad-words)[ Packagist](https://packagist.org/packages/oliveris/bad-words)[ RSS](/packages/oliveris-bad-words/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (5)Used By (0)

Bad Words
=========

[](#bad-words)

Filters through text and cleans the input of bad words found.

### Usage

[](#usage)

Pull in the composer package by running the command below:

```
composer require oliveris/bad-words

```

Import the BadWords namespace into the class (autoloading)

```
use BadWords\BadWords;

```

Examples
--------

[](#examples)

### Checking if there are bad words in a string

[](#checking-if-there-are-bad-words-in-a-string)

Below is an example that returns a bool value if a bad word was detected within the given string.

```
BadWords::checkForBadWords($test_string)

```

### Checking if there are bad words found within a string

[](#checking-if-there-are-bad-words-found-within-a-string)

Below is an example that returns an array value of bad words was detected within the given string.

```
BadWords::getBadWords($test_string)

```

### Replacing any bad words found within a string

[](#replacing-any-bad-words-found-within-a-string)

Below is an example that returns a clean string, it replaces any bad words found within a string with random words that the user has set.

```
BadWords::setReplacementWords([
    'hello',
    'world',
    'tree',
    'desk',
    'computer'
]);

BadWords::replaceBadWords($test_string);

```

### Replacing any bad words found within a string with a mask of characters

[](#replacing-any-bad-words-found-within-a-string-with-a-mask-of-characters)

Below is an example that returns a clean string, it replaces any bad words found with a mask the same length as the bad words.

```
BadWords::maskBadWords($test_string)

```

### Unmasking the masked words

[](#unmasking-the-masked-words)

Below is an example that returns the string in its original unmasked form.

```
BadWords::unMaskBadWords($masked_string);

```

### Set the filter words (will replace the preset)

[](#set-the-filter-words-will-replace-the-preset)

```
BadWords::setFilterWords([
    'moody',
    'fat',
    'cunt'
]);

```

### Add to the array of filter words

[](#add-to-the-array-of-filter-words)

```
BadWords::addToFilterWords([
    'bollocks',
    'shit',
    'slag'
]);

```

### License

[](#license)

BadWords is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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

Every ~10 days

Total

3

Last Release

2914d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20270046?v=4)[Sam](/maintainers/oliveris)[@oliveris](https://github.com/oliveris)

---

Top Contributors

[![oliveris](https://avatars.githubusercontent.com/u/20270046?v=4)](https://github.com/oliveris "oliveris (11 commits)")

---

Tags

swearbad words

### Embed Badge

![Health badge](/badges/oliveris-bad-words/health.svg)

```
[![Health](https://phpackages.com/badges/oliveris-bad-words/health.svg)](https://phpackages.com/packages/oliveris-bad-words)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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