Download the PHP package scherhak/is-gibberish without Composer
On this page you can find all versions of the php package scherhak/is-gibberish. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download scherhak/is-gibberish
More information about scherhak/is-gibberish
Files in scherhak/is-gibberish
Package is-gibberish
Short Description Zero-dependency PHP package for detecting obvious gibberish input using fast heuristics.
License MIT
Informations about the package is-gibberish
is-gibberish
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?
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
- 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
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:
You can also override heuristic weights for a single boolean check:
🔎 Detailed Analysis
You can override configuration for a single analysis call:
If you prefer to configure the detector up front, you can still pass a DetectorConfig to the constructor:
⚙️ Configuration Options
Both isGibberish() and analyze() accept an optional second argument:
Supported options:
threshold(float): Overrides the score threshold for this single call.weights(array<string, float>): Overrides selected heuristic weights for this single call. Missing keys keep their default values.keyboard_rows(list<string>): Replaces the keyboard row list for this single call.
Available heuristic weight keys:
special_character_densityrepetitionkeyboard_patternvowel_consonant_balancecharacter_distributiontoken_pattern
Default configuration:
threshold:45.0weights.special_character_density:30.0weights.repetition:30.0weights.keyboard_pattern:50.0weights.vowel_consonant_balance:20.0weights.character_distribution:20.0weights.token_pattern:35.0keyboard_rows:['qwertyuiop', 'asdfghjkl', 'zxcvbnm', 'qwertzuiop', 'yxcvbnm']
🧠 Current Heuristics
- Special character density
- Repeated characters and repeated short blocks
- Keyboard row patterns such as
asdfghjklandqwertzuiop - Vowel to consonant imbalance
- Unnatural character-class distribution
- Suspicious multi-token fragment patterns
🛠️ Development
Install development dependencies:
Run the test suite:
For contribution guidelines, development workflow and testing details, see CONTRIBUTING.md.