Passed
Push — master ( ddfa0e...f4f8b3 )
by Alexander
12:23
created

EchoHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 1
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\VarDumper\Handler;
6
7
use Yiisoft\VarDumper\HandlerInterface;
8
use Yiisoft\VarDumper\VarDumper;
9
10
final class EchoHandler implements HandlerInterface
11
{
12 6
    public function handle(mixed $variable, int $depth, bool $highlight = false): void
13
    {
14 6
        $varDumper = VarDumper::create($variable);
15 6
        $output = $varDumper->asString($depth);
16
17 6
        if ($highlight) {
18 1
            $result = highlight_string("<?php\n" . $output, true);
19 1
            $output = preg_replace('/&lt;\\?php<br \\/>/', '', $result, 1);
20
        }
21
22 6
        echo $output;
23
    }
24
}
25