flack /
openpsa
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @package midcom.compat |
||
| 4 | * @author CONTENT CONTROL http://www.contentcontrol-berlin.de/ |
||
| 5 | * @copyright CONTENT CONTROL http://www.contentcontrol-berlin.de/ |
||
| 6 | * @license http://www.gnu.org/licenses/gpl.html GNU General Public License |
||
| 7 | */ |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Support for interactions with environment |
||
| 11 | * |
||
| 12 | * @package midcom.compat |
||
| 13 | */ |
||
| 14 | class midcom_compat_environment |
||
| 15 | { |
||
| 16 | private static array $_headers = []; |
||
| 17 | |||
| 18 | 17 | public static function header(string $string, bool $replace = true, int $http_response_code = 0) |
|
| 19 | { |
||
| 20 | 17 | if (!defined('OPENPSA2_UNITTEST_RUN')) { |
|
| 21 | header($string, $replace, $http_response_code); |
||
| 22 | } else { |
||
| 23 | 17 | self::$_headers[] = [ |
|
| 24 | 17 | 'value' => $string, |
|
| 25 | 17 | 'replace' => $replace, |
|
| 26 | 17 | 'http_response_code' => $http_response_code |
|
| 27 | 17 | ]; |
|
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | public static function stop_request(string $message) |
||
| 32 | { |
||
| 33 | if (!defined('OPENPSA2_UNITTEST_RUN')) { |
||
| 34 | exit($message); |
||
|
0 ignored issues
–
show
|
|||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | 674 | public static function flush_registered_headers() : array |
|
| 39 | { |
||
| 40 | 674 | $headers = self::$_headers; |
|
| 41 | 674 | self::$_headers = []; |
|
| 42 | 674 | return $headers; |
|
| 43 | } |
||
| 44 | } |
||
| 45 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.