A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
use PhpSpellcheck\MisspellingFinder;
6
use PhpSpellcheck\MisspellingHandler\EchoHandler;
7
use PhpSpellcheck\Spellchecker\Aspell;
8
use PhpSpellcheck\TextInterface;
9
use PhpSpellcheck\TextProcessor\TextProcessorInterface;
10
11
require_once __DIR__ . '/../vendor/autoload.php';
12
13
// My custom text processor that replaces "_" by " "
14
$customTextProcessor = new class () implements TextProcessorInterface {
15
    public function process(TextInterface $text): TextInterface
16
    {
17
        $contentProcessed = str_replace('_', ' ', $text->getContent());
18
19
        return $text->replaceContent($contentProcessed);
20
    }
21
};
22
23
$misspellingFinder = new MisspellingFinder(
24
    Aspell::create(), // Creates aspell spellchecker pointing to "aspell" as it's binary path
25
    new EchoHandler(), // Handles all the misspellings found by echoing their information
26
    $customTextProcessor
27
);
28
29
// using a string
30
$misspellingFinder->find('It\'s_a_mispelling', ['en_US']);
0 ignored issues
show
Bug introduced by
'It's_a_mispelling' of type string is incompatible with the type iterable expected by parameter $source of PhpSpellcheck\MisspellingFinder::find(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
$misspellingFinder->find(/** @scrutinizer ignore-type */ 'It\'s_a_mispelling', ['en_US']);
Loading history...
31
// word: mispelling | line: 1 | offset: 7 | suggestions: mi spelling,mi-spelling,misspelling | context: []
32