EchoHandler::handle()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
nc 2
nop 1
dl 0
loc 13
rs 9.9666
c 1
b 0
f 0
ccs 10
cts 10
cp 1
crap 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