PHPackages                             scherhak/is-gibberish - 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. scherhak/is-gibberish

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

scherhak/is-gibberish
=====================

Zero-dependency PHP package for detecting obvious gibberish input using fast heuristics.

v0.1.0(3w ago)00MITPHPPHP ^8.2CI passing

Since May 19Pushed 3w agoCompare

[ Source](https://github.com/scherhak/is-gibberish)[ Packagist](https://packagist.org/packages/scherhak/is-gibberish)[ RSS](/packages/scherhak-is-gibberish/feed)WikiDiscussions main Synced 1w ago

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

is-gibberish
============

[](#is-gibberish)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/5814289f8aa8cd4671b9582f7c4172d2d1af7fccd603b5d707234f0e02ad69d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e322d3838393262662e737667)](https://camo.githubusercontent.com/5814289f8aa8cd4671b9582f7c4172d2d1af7fccd603b5d707234f0e02ad69d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e322d3838393262662e737667)

A tiny, **zero-dependency** PHP package to detect if a string is just random keyboard smashing or "gibberish". Perfect for pre-filtering contact forms before sending emails.

🚀 Why use this?
---------------

[](#-why-use-this)

Bots and frustrated users often fill form fields with nonsense like `asdfghjkl`, `sdfa sdfas df sadf asdfas asdf`, or `kfkJHzgHjb6)?)7)`. This package helps you identify these strings using fast heuristic analysis instead of heavy machine learning.

✨ Features
----------

[](#-features)

- **Ultra Lightweight:** No dependencies, just pure PHP.
- **Fast:** Uses lightweight heuristics and pattern distribution for near-instant results.
- **Multilingual:** Correctly handles German Umlauts (ä, ö, ü) and accented letters conservatively.
- **Customizable:** Adjust thresholds, heuristic weights and keyboard rows globally or per call.
- **Explainable:** Optional analysis result with score and triggered reasons.

📦 Installation
--------------

[](#-installation)

```
composer require yourname/is-gibberish
```

```
use IsGibberish\Detector;

$detector = new Detector();

$input = "asdf 24qf waefasdf arg aerg ergeara asd";

if ($detector->isGibberish($input)) {
    // Handle as invalid input
    echo "Please enter a real message.";
}
```

The default configuration is tuned to detect the most common gibberish patterns in typical form submissions, including contact forms, support requests, and checkout-related text fields. For most applications, it should work well out of the box without additional tuning.

Per-call overrides are also supported when you need to tune the detector for a specific field, workflow, or validation policy:

```
if ($detector->isGibberish($input, [
    'threshold' => 35.0,
])) {
    echo "Please enter a real message.";
}
```

You can also override heuristic weights for a single boolean check:

```
if ($detector->isGibberish($input, [
    'weights' => [
        'token_pattern' => 30.0,
        'keyboard_pattern' => 70.0,
    ],
])) {
    echo "Please enter a real message.";
}
```

🔎 Detailed Analysis
-------------------

[](#-detailed-analysis)

```
$result = $detector->analyze("asdf 24qf waefasdf arg aerg ergeara asd");

$result->isGibberish(); // true
$result->score();       // e.g. 58.0
$result->threshold();   // e.g. 45.0
$result->reasons();     // triggered heuristic reasons
$result->breakdown();   // heuristic scores
```

You can override configuration for a single analysis call:

```
$result = $detector->analyze($input, [
    'threshold' => 35.0,
    'weights' => [
        'keyboard_pattern' => 70.0,
        'token_pattern' => 30.0,
    ],
    'keyboard_rows' => ['qwertyuiop', 'asdfghjkl', 'zxcvbnm'],
]);
```

If you prefer to configure the detector up front, you can still pass a `DetectorConfig` to the constructor:

```
use IsGibberish\Config\DetectorConfig;
use IsGibberish\Detector;

$config = DetectorConfig::default()
    ->withThreshold(40.0)
    ->withMergedWeights([
        'keyboard_pattern' => 60.0,
    ]);

$detector = new Detector($config);
```

⚙️ Configuration Options
------------------------

[](#️-configuration-options)

Both `isGibberish()` and `analyze()` accept an optional second argument:

```
$result = $detector->analyze($input, [
    'threshold' => 35.0,
    'weights' => [
        'keyboard_pattern' => 70.0,
    ],
    'keyboard_rows' => ['qwertyuiop', 'asdfghjkl', 'zxcvbnm'],
]);
```

Supported options:

- `threshold` (`float`): Overrides the score threshold for this single call.
- `weights` (`array`): Overrides selected heuristic weights for this single call. Missing keys keep their default values.
- `keyboard_rows` (`list`): Replaces the keyboard row list for this single call.

Available heuristic weight keys:

- `special_character_density`
- `repetition`
- `keyboard_pattern`
- `vowel_consonant_balance`
- `character_distribution`
- `token_pattern`

Default configuration:

- `threshold`: `45.0`
- `weights.special_character_density`: `30.0`
- `weights.repetition`: `30.0`
- `weights.keyboard_pattern`: `50.0`
- `weights.vowel_consonant_balance`: `20.0`
- `weights.character_distribution`: `20.0`
- `weights.token_pattern`: `35.0`
- `keyboard_rows`: `['qwertyuiop', 'asdfghjkl', 'zxcvbnm', 'qwertzuiop', 'yxcvbnm']`

🧠 Current Heuristics
--------------------

[](#-current-heuristics)

- Special character density
- Repeated characters and repeated short blocks
- Keyboard row patterns such as `asdfghjkl` and `qwertzuiop`
- Vowel to consonant imbalance
- Unnatural character-class distribution
- Suspicious multi-token fragment patterns

🛠️ Development
--------------

[](#️-development)

Install development dependencies:

```
composer install
```

Run the test suite:

```
vendor/bin/phpunit
```

For contribution guidelines, development workflow and testing details, see [CONTRIBUTING.md](/Users/sascha/develop/is-gibberish/CONTRIBUTING.md:1).

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance96

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

22d ago

### Community

Maintainers

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

---

Top Contributors

[![scherhak](https://avatars.githubusercontent.com/u/4221861?v=4)](https://github.com/scherhak "scherhak (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/scherhak-is-gibberish/health.svg)

```
[![Health](https://phpackages.com/badges/scherhak-is-gibberish/health.svg)](https://phpackages.com/packages/scherhak-is-gibberish)
```

###  Alternatives

[sarfraznawaz2005/loading

Laravel package to add loading indicator to pages while page is loading.

4812.0k](/packages/sarfraznawaz2005-loading)

PHPackages © 2026

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