bd()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
rs 10
1
<?php
2
/**
3
 * Webino (http://webino.sk/)
4
 *
5
 * @link        https://github.com/webino/exceptions for the canonical source repository
6
 * @copyright   Copyright (c) 2019 Webino, s. r. o. (http://webino.sk/)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace Webino;
12
13
use Tracy\Debugger;
14
use Webino\DevException;
15
16
/**
17
 * Alias for var_dump()
18
 *
19
 * @param mixed $subject
20
 */
21
function d($subject)
22
{
23
    var_dump($subject);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($subject) looks like debug code. Are you sure you do not want to remove it?
Loading history...
24
}
25
26
/**
27
 * Diyng var_dump()
28
 *
29
 * @param mixed $subject
30
 */
31
function dd($subject)
32
{
33
    var_dump($subject);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($subject) looks like debug code. Are you sure you do not want to remove it?
Loading history...
34
    exit;
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...
35
}
36
37
/**
38
 * Alias for print_r() scream
39
 *
40
 * @param mixed $subject
41
 */
42
function p($subject)
43
{
44
    if (class_exists(Debugger::class)) {
45
        Debugger::dump($subject);
46
        return;
47
    }
48
49
    print_r($subject);
50
}
51
52
/**
53
 * Dying print_r() scream
54
 *
55
 * @param mixed $subject
56
 */
57
function pd($subject)
58
{
59
    if (class_exists(Debugger::class)) {
60
        Debugger::dump($subject);
61
        exit;
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...
62
    }
63
64
    print_r($subject);
65
    exit;
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...
66
}
67
68
/**
69
 * Alias for print_r() return
70
 *
71
 * @param mixed $subject
72
 * @return string
73
 */
74
function pr($subject)
75
{
76
    if (class_exists(Debugger::class)) {
77
        return Debugger::dump($subject, true);
78
    }
79
80
    return print_r($subject, true);
81
}
82
83
/**
84
 * Debugger bar dump
85
 *
86
 * @param mixed $subject
87
 */
88
function bd($subject)
89
{
90
    if (class_exists(Debugger::class)) {
91
        Debugger::barDump($subject);
92
    }
93
}
94
95
/**
96
 * Web debugger break point
97
 *
98
 * Sometimes is useful by throwing an exception to check a backtrace.
99
 *
100
 * @param string $msg
101
 * @throws Exception
102
 */
103
function e(string $msg = '')
104
{
105
    throw new DevException($msg);
106
}
107