Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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
    public function startOutputBuffering()
17
    {
18
        return ob_start();
19
    }
20
 
21
    /**
22
     * @param callable $handler
23
     * @param int      $types
24
     *
25
     * @return callable|null
26
     */
27
    public function setErrorHandler(callable $handler, $types = 'use-php-defaults')
28
    {
29
        // Since PHP 5.4 the constant E_ALL contains all errors (even E_STRICT)
30
        if ($types === 'use-php-defaults') {
31
            $types = E_ALL;
32
        }
33
        return set_error_handler($handler, $types);
34
    }
35
 
36
    /**
37
     * @param callable $handler
38
     *
39
     * @return callable|null
40
     */
41
    public function setExceptionHandler(callable $handler)
42
    {
43
        return set_exception_handler($handler);
44
    }
45
 
46
    /**
47
     * @return void
48
     */
49
    public function restoreExceptionHandler()
50
    {
51
        restore_exception_handler();
52
    }
53
 
54
    /**
55
     * @return void
56
     */
57
    public function restoreErrorHandler()
58
    {
59
        restore_error_handler();
60
    }
61
 
62
    /**
63
     * @param callable $function
64
     *
65
     * @return void
66
     */
67
    public function registerShutdownFunction(callable $function)
68
    {
69
        register_shutdown_function($function);
70
    }
71
 
72
    /**
73
     * @return string|false
74
     */
75
    public function cleanOutputBuffer()
76
    {
77
        return ob_get_clean();
78
    }
79
 
80
    /**
81
     * @return int
82
     */
83
    public function getOutputBufferLevel()
84
    {
85
        return ob_get_level();
86
    }
87
 
88
    /**
89
     * @return bool
90
     */
91
    public function endOutputBuffering()
92
    {
93
        return ob_end_clean();
94
    }
95
 
96
    /**
97
     * @return void
98
     */
99
    public function flushOutputBuffer()
100
    {
101
        flush();
102
    }
103
 
104
    /**
105
     * @return int
106
     */
107
    public function getErrorReportingLevel()
108
    {
109
        return error_reporting();
110
    }
111
 
112
    /**
113
     * @return array|null
114
     */
115
    public function getLastError()
116
    {
117
        return error_get_last();
118
    }
119
 
120
    /**
121
     * @param int $httpCode
122
     *
123
     * @return int
124
     */
125
    public function setHttpResponseCode($httpCode)
126
    {
127
        if (!headers_sent()) {
128
            // Ensure that no 'location' header is present as otherwise this
129
            // will override the HTTP code being set here, and mask the
130
            // expected error page.
131
            header_remove('location');
132
        }
133
 
134
        return http_response_code($httpCode);
135
    }
136
 
137
    /**
138
     * @param int $exitStatus
139
     */
140
    public function stopExecution($exitStatus)
141
    {
142
        exit($exitStatus);
143
    }
144
}