PHPackages                             bert-w/typomaniac - 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. bert-w/typomaniac

ActiveLibrary

bert-w/typomaniac
=================

Create deliberate spelling mistakes or typos in text.

v1.0.0(6y ago)07MITPHPPHP &gt;=5.6.0

Since May 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/bert-w/typomaniac)[ Packagist](https://packagist.org/packages/bert-w/typomaniac)[ RSS](/packages/bert-w-typomaniac/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

bert-w/typomaniac
=================

[](#bert-wtypomaniac)

[![Latest Stable Version](https://camo.githubusercontent.com/806b05dcfffac4639f35612294744f752ed4df318cf43a1e72790c195e746b63/68747470733a2f2f706f7365722e707567782e6f72672f626572742d772f7479706f6d616e6961632f762f737461626c65)](https://packagist.org/packages/bert-w/typomaniac)[![Total Downloads](https://camo.githubusercontent.com/c54fc80a739d0bc7d3e7ae699a81f1f9391c51c67c963a11dc9934a376e6efe9/68747470733a2f2f706f7365722e707567782e6f72672f626572742d772f7479706f6d616e6961632f646f776e6c6f616473)](https://packagist.org/packages/bert-w/typomaniac)[![License](https://camo.githubusercontent.com/6c79d130fbd0c034c1c482478057661276ab76acc7325f48a2ad6d0c38971dfd/68747470733a2f2f706f7365722e707567782e6f72672f626572742d772f7479706f6d616e6961632f6c6963656e7365)](https://packagist.org/packages/bert-w/typomaniac)

A library that creates deliberate spelling mistakes/typos for you.

### Installation instructions

[](#installation-instructions)

`composer require bert-w/typomaniac`

### Quick start

[](#quick-start)

##### Code Samples

[](#code-samples)

```
$typomaniac = new \BertW\Typomaniac\Typomaniac([
    // Chance of an error (0 - 100), decided per character (default).
    'chance' => 2,
    // Usable mistakes (default).
    'mistakes' => [
        BertW\Typomaniac\Mistakes\CharacterAccents::class,
        BertW\Typomaniac\Mistakes\CharacterRepeat::class,
        BertW\Typomaniac\Mistakes\CharactersFlip::class,
        BertW\Typomaniac\Mistakes\CharacterSkip::class,
        BertW\Typomaniac\Mistakes\KeyboardTypo::class,
        BertW\Typomaniac\Mistakes\CharacterChangeCapitalization::class,
    ],
]);

$result = $typomaniac->typo('Please create random typo\'s in this text. The longer the text the more chance of an error!');
```

It has a convenient `__toString()` method to get the actual string output:

```
echo $result;

// Result:
// 'Please create randoom typo's in tihs text. The longer the text the more chance of an  error!'
```

`$result` also has more properties that could be useful:

```
class Result {
    /** @var array List of used mistakes and their frequency. */
    public $usedMistakes = [];

    /** @var array List of available mistakes. */
    public $mistakes = [];

    /** @var int The chance of a mistake (0 - 100). */
    public $chance;
}
```

### Explanation of the various `Mistake` types

[](#explanation-of-the-various-mistake-types)

- `CharacterAccents`: Make a mistake for misentered accent characters. `ü => "u || u"`.
- `CharacterRepeat`: Repeat a character. `a => aa`
- `CharactersFlip`: Flip a character with the previous one. `af => fa`
- `CharacterSkip`: Skip a key stroke (simply returns an empty string). `a => (empty)`
- `KeyboardTypo`: Choose a random key that is physically near another key on a QWERTY keyboard. `a => q`
- `CharacterChangeCapitalization`: Change the character capitalization to either lower or uppercase. `A => a`

#### Adding your own mistake type

[](#adding-your-own-mistake-type)

Before trying to add your own mistake class, please read the **Inner workings** below first.

To add your own spelling mistake, simply create a class and extend it from `BertW\Typomaniac\Mistakes\Mistake`. See the source code for examples.

```
// Add a mistake to the default mistake options (or assign it in the constructor).
$typomaniac->addMistake(\MyLibrary\FindSynonym::class);
$result = $typomaniac->typo(...);
```

### Inner workings

[](#inner-workings)

- Typomaniac loops your input string one character at a time.
- Per each character, the `$chance` property is used to determine whether a mistake should take place.
- Once this happens, one of the `Mistake` classes is randomly chosen as the current active Mistake.
- As long as the `Mistake->end()` function returns `false`, it will continue to push characters to the Mistake `input`. This allows us to send a substring of arbitrary length of the input to the Mistake class. For instance, the `CharactersFlip` class expects 2 characters and returns the 2 characters but flipped.
- Once the `Mistake->end()` function returns `true`, the Mistake class is asked to make a mistake on the received input. i.e. `CharactersFlip` would return `'af'` for a given input string `'fa'`.
- The loop is continued, so a new Mistake can take place (or the end is reached, in which case, it stops).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Unknown

Total

1

Last Release

2192d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10498595?v=4)[Bert](/maintainers/bert-w)[@bert-w](https://github.com/bert-w)

---

Top Contributors

[![bert-w](https://avatars.githubusercontent.com/u/10498595?v=4)](https://github.com/bert-w "bert-w (2 commits)")

---

Tags

randomspellingtypostypomistake

### Embed Badge

![Health badge](/badges/bert-w-typomaniac/health.svg)

```
[![Health](https://phpackages.com/badges/bert-w-typomaniac/health.svg)](https://phpackages.com/packages/bert-w-typomaniac)
```

###  Alternatives

[paragonie/random_compat

PHP 5.x polyfill for random\_bytes() and random\_int() from PHP 7

8.2k655.0M405](/packages/paragonie-random-compat)[ircmaxell/random-lib

A Library For Generating Secure Random Numbers

84130.2M119](/packages/ircmaxell-random-lib)[wapmorgan/morphos

A morphological solution for Russian and English language written completely in PHP. Provides classes to inflect personal names, geographical names, decline and pluralize nouns, generate cardinal and ordinal numerals, spell out money amounts and time.

8351.3M7](/packages/wapmorgan-morphos)[mistic100/randomcolor

Generate attractive random colors

2431.4M6](/packages/mistic100-randomcolor)[peckphp/peck

Peck is a powerful CLI tool designed to identify pure wording or spelling (grammar) mistakes in your codebase.

474325.3k97](/packages/peckphp-peck)[tigitz/php-spellchecker

Provides an easy way to spellcheck multiple text source by many spellcheckers, directly from PHP

309498.4k1](/packages/tigitz-php-spellchecker)

PHPackages © 2026

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