mlequer / typos-generator
A typos generator
v2.0.1
2020-02-14 20:12 UTC
Requires
- php: >=7.4
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.8
- phpmd/phpmd: @stable
- phpstan/phpstan: ^0.12.9
- squizlabs/php_codesniffer: ^3.0
- symfony/phpunit-bridge: ^5.0
This package is auto-updated.
Last update: 2024-12-19 02:38:07 UTC
README
Typos generator utility
Installation
Install the latest version with
$ composer require mlequer/typos-generator
>if you are looking for the command line generator, use
mlequer/typos-generator-command
instead
Usage
// if needed
// require "vendor/autoload.php";
use MLequer\Component\Typos\Generator\TypoGenerator;
use MLequer\Component\Typos\Provider\ChainTyposProvider;
use MLequer\Component\Typos\Provider\HomophoneTyposProvider;
use MLequer\Component\Typos\Provider\TyposProviderCollection;
$typos = new HomophoneTyposProvider();
// usage without chain:
$g = new TypoGenerator($typos);
$res = $g->generateTypos("computer"); // return a Generator
$res = $g->generateTyposAsArray("something"); // return an array
// using multiple typos providers
$typos = new HomophoneTyposProvider();
$collection = new TyposProviderCollection();
$collection->addProvider($typos)
// ->addProvider(new WrongKeyTyposProvider)
// ->addProvider( ... )
// ...
;
// use the special chain provider
$chain = new ChainTyposProvider($collection);
$g = new TypoGenerator($typos);
// return a Generator
$res = $g->generateTypos("computer");
foreach ($res as $t) {
echo $t . "\n";
}
// return an array
$res = $g->generateTyposAsArray("something");
var_dump($res);
You can create your own provider by extending TyposProviderInterface