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

dump()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 1
cp 0
crap 2
rs 10
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
use Yiisoft\VarDumper\VarDumper;
6
7
if (!function_exists('d')) {
8
    /**
9
     * Prints variables.
10
     *
11
     * @param mixed ...$variables Variables to be dumped.
12
     *
13
     * @see \Yiisoft\VarDumper\VarDumper::dump()
14
     *
15
     * @psalm-suppress MixedAssignment
16
     */
17
    function d(mixed ...$variables): void
18
    {
19 2
        $highlight = PHP_SAPI !== 'cli';
20
21 2
        foreach ($variables as $variable) {
22 2
            VarDumper::dump($variable, 10, $highlight);
23 2
            echo $highlight ? '<br>' : PHP_EOL;
24
        }
25
    }
26
}
27
28
if (!function_exists('dd')) {
29
    /**
30
     * Prints variables and terminate the current script.
31
     *
32
     * @param mixed ...$variables Variables to be dumped.
33
     *
34
     * @see \Yiisoft\VarDumper\VarDumper::dump()
35
     *
36
     * @psalm-suppress MixedAssignment
37
     */
38
    function dd(mixed ...$variables): void
39
    {
40
        d(...$variables);
41
42
        die(0);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
43
    }
44
}
45
46
if (!function_exists('dump')) {
47
    /**
48
     * Prints variables and terminate the current script.
49
     *
50
     * @param mixed ...$variables Variables to be dumped.
51
     *
52
     * @see d()
53
     *
54
     * @psalm-suppress MixedAssignment
55
     */
56
    function dump(mixed ...$variables): void
57
    {
58
        d(...$variables);
59
    }
60
}
61