EchoHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 18
rs 10
c 1
b 0
f 0
ccs 10
cts 10
cp 1
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpSpellcheck\MisspellingHandler;
6
7
use PhpSpellcheck\MisspellingInterface;
8
9
class EchoHandler implements MisspellingHandlerInterface
10
{
11
    /**
12
     * @param MisspellingInterface[] $misspellings
13
     */
14 1
    public function handle(iterable $misspellings): void
15
    {
16 1
        foreach ($misspellings as $misspelling) {
17 1
            $output = sprintf(
18 1
                'word: %s | line: %d | offset: %d | suggestions: %s | context: %s' . PHP_EOL,
19 1
                $misspelling->getWord(),
20 1
                $misspelling->getLineNumber(),
21 1
                $misspelling->getOffset(),
22 1
                $misspelling->hasSuggestions() ? implode(',', $misspelling->getSuggestions()) : '',
23 1
                \Safe\json_encode($misspelling->getContext())
24
            );
25
26 1
            echo $output;
27
        }
28 1
    }
29
}
30