Test Failed
Pull Request — master (#94)
by Dmitriy
03:17 queued 16s
created

EchoHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 13
rs 10
c 1
b 0
f 0
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
class EchoHandler implements HandlerInterface
11
{
12
    public function handle(mixed $variable, int $depth, bool $highlight = false): void
13
    {
14
        $varDumper = VarDumper::create($variable);
15
        $output = $varDumper->asString($depth);
16
17
        if ($highlight) {
18
            $result = highlight_string("<?php\n" . $output, true);
19
            $output = preg_replace('/&lt;\\?php<br \\/>/', '', $result, 1);
20
        }
21
22
        echo $output;
23
    }
24
}
25