1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Whoops - php errors for cool kids |
4
|
|
|
* @author Filipe Dobreira <http://github.com/filp> |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Whoops\Util; |
8
|
|
|
|
9
|
|
|
class SystemFacade |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Turns on output buffering. |
13
|
|
|
* |
14
|
|
|
* @return bool |
15
|
|
|
*/ |
16
|
2 |
|
public function startOutputBuffering() |
17
|
|
|
{ |
18
|
2 |
|
return ob_start(); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param callable $handler |
23
|
|
|
* @param int $types |
24
|
|
|
* |
25
|
|
|
* @return string|null |
26
|
|
|
*/ |
27
|
6 |
|
public function setErrorHandler(callable $handler, $types = E_ALL | E_STRICT) |
28
|
|
|
{ |
29
|
6 |
|
return set_error_handler($handler, $types); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param callable $handler |
34
|
|
|
* |
35
|
|
|
* @return string|null |
36
|
|
|
*/ |
37
|
5 |
|
public function setExceptionHandler(callable $handler) |
38
|
|
|
{ |
39
|
5 |
|
return set_exception_handler($handler); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return bool |
44
|
|
|
*/ |
45
|
1 |
|
public function restoreExceptionHandler() |
46
|
|
|
{ |
47
|
1 |
|
return restore_exception_handler(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return bool |
52
|
|
|
*/ |
53
|
1 |
|
public function restoreErrorHandler() |
54
|
|
|
{ |
55
|
1 |
|
return restore_error_handler(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param callable $function |
60
|
|
|
* |
61
|
|
|
* @return mixed |
62
|
|
|
*/ |
63
|
5 |
|
public function registerShutdownFunction(callable $function) |
64
|
|
|
{ |
65
|
5 |
|
return register_shutdown_function($function); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string|false |
70
|
|
|
*/ |
71
|
2 |
|
public function cleanOutputBuffer() |
72
|
|
|
{ |
73
|
2 |
|
return ob_get_clean(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return int |
78
|
|
|
*/ |
79
|
1 |
|
public function getOutputBufferLevel() |
80
|
|
|
{ |
81
|
1 |
|
return ob_get_level(); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return bool |
86
|
|
|
*/ |
87
|
1 |
|
public function endOutputBuffering() |
88
|
|
|
{ |
89
|
1 |
|
return ob_end_clean(); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return void |
94
|
|
|
*/ |
95
|
1 |
|
public function flushOutputBuffer() |
96
|
|
|
{ |
97
|
1 |
|
flush(); |
98
|
1 |
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return int |
102
|
|
|
*/ |
103
|
4 |
|
public function getErrorReportingLevel() |
104
|
|
|
{ |
105
|
4 |
|
return error_reporting(); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return array|null |
110
|
|
|
*/ |
111
|
1 |
|
public function getLastError() |
112
|
|
|
{ |
113
|
1 |
|
return error_get_last(); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param int $httpCode |
118
|
|
|
* |
119
|
|
|
* @return int |
120
|
|
|
*/ |
121
|
1 |
|
public function setHttpResponseCode($httpCode) |
122
|
|
|
{ |
123
|
1 |
|
return http_response_code($httpCode); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param int $exitStatus |
128
|
|
|
*/ |
129
|
|
|
public function stopExecution($exitStatus) |
130
|
|
|
{ |
131
|
|
|
exit($exitStatus); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|