| 1 | <?php |
||
| 12 | abstract class Ajax { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Create a new response object |
||
| 16 | */ |
||
| 17 | |||
| 18 | public static function createResponse(array $data = []) : Ajax\Response { |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Check if a given variable is a response object |
||
| 25 | */ |
||
| 26 | |||
| 27 | public static function isResponse($object) : bool { |
||
| 28 | |||
| 29 | return ($object instanceof Ajax\Response); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Output JSON data contained in a given response object |
||
| 34 | */ |
||
| 35 | |||
| 36 | public static function output(Ajax\Response $response) { |
||
| 37 | |||
| 38 | JSON::output($response->getData()); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 |