1
|
|
|
<?php |
2
|
|
|
namespace PHPPgAdmin; |
|
|
|
|
3
|
|
|
|
4
|
|
|
trait HelperTrait |
|
|
|
|
5
|
|
|
{ |
6
|
|
|
public function halt($msg) |
|
|
|
|
7
|
|
|
{ |
8
|
|
|
$body = $this->container->responseobj->getBody(); |
|
|
|
|
9
|
|
|
$body->write($msg); |
10
|
|
|
throw new \Slim\Exception\SlimException($this->container->requestobj, $this->container->responseobj); |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Receives N parameters and sends them to the console adding where was it called from |
15
|
|
|
* @return [type] [description] |
|
|
|
|
16
|
|
|
*/ |
|
|
|
|
17
|
|
|
public function prtrace() |
18
|
|
|
{ |
19
|
|
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4); |
20
|
|
|
|
21
|
|
|
$btarray0 = ([ |
22
|
|
|
'class0' => $backtrace[3]['class'], |
23
|
|
|
'type0' => $backtrace[3]['type'], |
24
|
|
|
'function0' => $backtrace[3]['function'], |
25
|
|
|
'spacer0' => ' ', |
26
|
|
|
'line0' => $backtrace[2]['line'], |
27
|
|
|
|
28
|
|
|
'spacer1' => "\n", |
29
|
|
|
|
30
|
|
|
'class1' => $backtrace[2]['class'], |
31
|
|
|
'type1' => $backtrace[2]['type'], |
32
|
|
|
'function1' => $backtrace[2]['function'], |
33
|
|
|
'spacer2' => ' ', |
34
|
|
|
'line1' => $backtrace[1]['line'], |
35
|
|
|
|
36
|
|
|
'spacer3' => "\n", |
37
|
|
|
|
38
|
|
|
'class2' => $backtrace[1]['class'], |
39
|
|
|
'type2' => $backtrace[1]['type'], |
40
|
|
|
'function2' => $backtrace[1]['function'], |
41
|
|
|
'spacer4' => ' ', |
42
|
|
|
'line2' => $backtrace[0]['line'], |
43
|
|
|
]); |
44
|
|
|
|
45
|
|
|
$tag = implode('', $btarray0); |
46
|
|
|
|
47
|
|
|
\PC::debug(func_get_args(), $tag); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public static function statictrace() |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); |
53
|
|
|
|
54
|
|
|
$btarray0 = ([ |
55
|
|
|
'class' => $backtrace[1]['class'], |
56
|
|
|
'type' => $backtrace[1]['type'], |
57
|
|
|
'function' => $backtrace[1]['function'], |
58
|
|
|
'spacer' => ' ', |
59
|
|
|
'line' => $backtrace[0]['line'], |
60
|
|
|
]); |
61
|
|
|
|
62
|
|
|
$tag = implode('', $btarray0); |
63
|
|
|
|
64
|
|
|
\PC::debug(func_get_args(), $tag); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Returns a string with html <br> variant replaced with a new line |
69
|
|
|
* @param string $msg [description] |
|
|
|
|
70
|
|
|
* @return string [description] |
|
|
|
|
71
|
|
|
*/ |
72
|
|
|
public static function br2ln(string $msg) |
73
|
|
|
{ |
74
|
|
|
return str_replace(['<br>', '<br/>', '<br />'], "\n", $msg); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|