Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
json_response | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
send | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb; |
15 | |
16 | /** |
17 | * JSON class |
18 | */ |
19 | class json_response |
20 | { |
21 | /** |
22 | * Send the data to the client and exit the script. |
23 | * |
24 | * @param array $data Any additional data to send. |
25 | * @param bool $exit Will exit the script if true. |
26 | */ |
27 | public function send($data, $exit = true) |
28 | { |
29 | header('Content-Type: application/json'); |
30 | echo json_encode($data); |
31 | |
32 | if ($exit) |
33 | { |
34 | garbage_collection(); |
35 | exit_handler(); |
36 | } |
37 | } |
38 | } |