Passed
Pull Request — master (#45)
by Evgeniy
02:07
created

dd()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
ccs 0
cts 3
cp 0
crap 6
rs 10
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(...$variables): void
18
    {
19
        foreach ($variables as $variable) {
20
            VarDumper::dump($variable, 10, PHP_SAPI !== 'cli');
21
        }
22
    }
23
}
24
25
if (!function_exists('dd')) {
26
    /**
27
     * Prints variables and terminate the current script.
28
     *
29
     * @param mixed ...$variables Variables to be dumped.
30
     *
31
     * @see \Yiisoft\VarDumper\VarDumper::dump()
32
     *
33
     * @psalm-suppress MixedAssignment
34
     */
35
    function dd(...$variables): void
36
    {
37
        foreach ($variables as $variable) {
38
            VarDumper::dump($variable, 10, PHP_SAPI !== 'cli');
39
        }
40
        die();
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...
41
    }
42
}
43