Passed
Branch master (fc4881)
by Eugene
03:18
created

debug.php ➔ ddc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
if ( ! function_exists('dd'))
4
{
5
    /**
6
     * Dump and die
7
     *
8
     * @param  mixed  $value One or many arguments
9
     * @return mixed
10
     */
11
    function dd($value)
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
This method's name is shorter than the configured minimum length of 3 characters.

Even though PHP does not care about the name of your methods, it is generally a good practice to choose method names which can be easily understood by other human readers.

Loading history...
12
    {
13
        if (php_sapi_name() === 'cli-server' || php_sapi_name() === "cli") {
14
            array_map(function($x) { var_export($x); echo PHP_EOL; }, func_get_args());
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $x. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
15
        } else {
16
            array_map(function($x) { var_dump($x); }, func_get_args());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($x); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
17
        }
18
        die;
0 ignored issues
show
Coding Style Compatibility introduced by
The function dd() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
19
    }
20
21
    /**
22
     * Dump and die with var_export instead of var_dump
23
     * @param $value
24
     */
25
    function ddc($value)
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
    {
27
        array_map(function($x) { var_export($x); echo PHP_EOL; }, func_get_args());
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $x. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
28
        die;
0 ignored issues
show
Coding Style Compatibility introduced by
The function ddc() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
29
    }
30
}
31