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

ActiveLibrary

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

a PHP lib for filtering bad words from strings

v0.1.1(3y ago)85.2k—0%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 1mo 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

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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

1232d 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)
```

PHPackages © 2026

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