PHPackages                             faresmts/safewords - 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. faresmts/safewords

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

faresmts/safewords
==================

a PHP lib for filtering bad words from strings

v0.1.1(3y ago)86.4k—1%MITPHPPHP &gt;=8.0

Since Jan 2Pushed 3y ago1 watchersCompare

[ Source](https://github.com/faresmts/safewords)[ Packagist](https://packagist.org/packages/faresmts/safewords)[ RSS](/packages/faresmts-safewords/feed)WikiDiscussions v0.1.1 Synced 2w ago

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

filter bad words from your php string
=====================================

[](#filter-bad-words-from-your-php-string)

Safewords is a package that can be used in any PHP framework, calling in a static method and returning the censored text or a boolean to know if is safe.

Support me staring this repository or connecting with me in [linkedin](https://www.linkedin.com/in/matheusfares/)
-----------------------------------------------------------------------------------------------------------------

[](#support-me-staring-this-repository-or-connecting-with-me-in-linkedin)

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

[](#installation)

You can install the package via composer:

```
composer require faresmts/safewords

```

Usage
-----

[](#usage)

This is the simplest way to call a safewords checker:

```
$isSafe = SafeWords::filter($text)
            ->isSafe()
            ->get();

```

And this is the way to call a safewords censor:

```
$censoredText = SafeWords::filter($text)
                   ->replace()
                   ->get();

```

Both methods can be called with useDictionary() function to add new words to block:

```
$isSafe = SafeWords::filter($text)
            ->useDictionary(['foo', 'bar'])
            ->isSafe()
            ->get();

$censoredText = SafeWords::filter($text)
                    ->useDictionary(['foo', 'bar'])
                    ->replace()
                    ->get();

```

### Functions

[](#functions)

- `filter(string $text)`: add the text you want to check.
- `useDictionary(array $userBadWords)`: add the words you want to block in SafeWords checker.
- `isSafe()`: method that evaluates whether the text is safe.
- `replace(string $replace = '*')`: method that replaces each character of the bad word with the variable inside $string. Default is '\*'.
- `get()`: get the result of the chosen method.

### Exceptions

[](#exceptions)

- The methods `isSafe()` and `replace()` cannot be called at the same time, throwing an exception if this happens.
- The method `useDictionary()` cannot be called after the `isSafe()` or `replace()`. It must be called before.

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Every ~0 days

Total

3

Last Release

1324d ago

### Community

Maintainers

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

---

Top Contributors

[![faresmts](https://avatars.githubusercontent.com/u/90094692?v=4)](https://github.com/faresmts "faresmts (13 commits)")

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/faresmts-safewords/health.svg)

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

###  Alternatives

[toplan/laravel-sms

A mobile phone number validation solution based on laravel

83580.2k2](/packages/toplan-laravel-sms)[drupal/coder

Coder is a library to review Drupal code.

3046.8M629](/packages/drupal-coder)[ph-7/eu-vat-validator

A simple and clean PHP class that validates EU VAT numbers against the central ec.europa.eu database (using the official europa API).

97510.7k1](/packages/ph-7-eu-vat-validator)[hyperf/validation

hyperf validation

122.2M213](/packages/hyperf-validation)[udokmeci/yii2-phone-validator

Modern Yii2 Phone validator wrapper on top of PhoneNumberUtil library also used by Android devices

36227.5k1](/packages/udokmeci-yii2-phone-validator)[snowcap/vat-validation

EU VAT number validation

10112.3k](/packages/snowcap-vat-validation)

PHPackages © 2026

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