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

EchoHandler::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
nc 2
nop 3
dl 0
loc 11
rs 10
c 1
b 0
f 0
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