Failed Conditions
Push — master ( 5e6761...398dce )
by Adrien
04:14 queued 01:57
created

_em()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
cc 1
rs 10
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
use Doctrine\ORM\EntityManager;
6
use Ecodev\Felix\Debug;
7
use GraphQL\Doctrine\Types;
8
use Laminas\Log\LoggerInterface;
9
10
/**
11
 * Returns the type registry
12
 *
13
 * @return Types
14
 */
15
function _types(): Types
16
{
17
    global $container;
18
19
    return $container->get(Types::class);
20
}
21
22
/**
23
 * Returns the EM
24
 *
25
 * @return EntityManager
26
 */
27
function _em(): EntityManager
28
{
29 7
    global $container;
30
31 7
    return $container->get(EntityManager::class);
32
}
33
34
/**
35
 * Returns logger
36
 *
37
 * @return LoggerInterface
38
 */
39
function _log(): LoggerInterface
40
{
41
    global $container;
42
43
    return $container->get(LoggerInterface::class);
44
}
45
46
/**
47
 * Export variables omitting array keys that are strictly numeric
48
 *
49
 * By default will output result
50
 *
51
 * @param mixed $data
52
 * @param bool $return
53
 *
54
 * @return string string representation of variable
55
 */
56
function ve($data, bool $return = false): string
57
{
58
    return Debug::export($data, $return);
59
}
60
61
/**
62
 * Dump all arguments
63
 */
64
function v(): void
65
{
66
    var_dump(func_get_args());
0 ignored issues
show
Security Debugging Code introduced by
var_dump(func_get_args()) looks like debug code. Are you sure you do not want to remove it?
Loading history...
67
}
68
69
/**
70
 * Dump all arguments and die
71
 */
72
function w(): void
73
{
74
    $isHtml = (PHP_SAPI !== 'cli');
75
    echo "\n_________________________________________________________________________________________________________________________" . ($isHtml ? '</br>' : '') . "\n";
76
    var_dump(func_get_args());
0 ignored issues
show
Security Debugging Code introduced by
var_dump(func_get_args()) looks like debug code. Are you sure you do not want to remove it?
Loading history...
77
    echo "\n" . ($isHtml ? '</br>' : '') . '_________________________________________________________________________________________________________________________' . ($isHtml ? '<pre>' : '') . "\n";
78
    debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
79
    echo '' . ($isHtml ? '</pre>' : '') . '_________________________________________________________________________________________________________________________' . ($isHtml ? '</br>' : '') . "\n";
80
    die("script aborted on purpose.\n");
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...
81
}
82