\JSendResponse
Generate a proper json response for (ajax) communication
- Author: Martijn Schenk
Synopsis
class JSendResponse
{
- // constants
- const STATUS_SUCCESS = 'success';
- const STATUS_FAIL = 'fail';
- const STATUS_ERROR = 'error';
- // methods
- public static JSendResponse parse()
- public void __construct()
- public string getJson()
- public $this setStatus()
- public string getStatus()
- public bool isSuccess()
- public bool isFail()
- public bool isError()
- public $this setData()
- public mixed getData()
- public bool hasData()
- public $this setCode()
- public int getCode()
- public $this setMessage()
- public string getMessage()
- public bool hasMessage()
- public array getStatusses()
Constants
Name | Value |
---|---|
STATUS_SUCCESS | 'success' |
STATUS_FAIL | 'fail' |
STATUS_ERROR | 'error' |
Members
private
- $code
—
int
Code of the response - $data
—
object|array
Data of the response - $message
—
string
Message of the response - $status
—
string
Status of the response
Methods
public
- __construct() — JSendResponse constructor.
- getCode() — Retrieve the code for this response
- getData() — Retrieve the data for this response
- getJson() — Retrieve the json response
- getMessage() — Retrieve the message for this response
- getStatus() — Retrieve the status for this response
- getStatusses() — Retrieve the statusses this response allows
- hasData() — Does this response have data?
- hasMessage() — Does this response have a message?
- isError() — Is the status for this response error?
- isFail() — Is the status for this response fail?
- isSuccess() — Is the status for this response success?
- parse() — Parse a JSend response json
- setCode() — Set the code for this response
- setData() — Set the data for this response
- setMessage() — Set the message for this response
- setStatus() — Set the status for this response