class Output

Represents the output to be shown to the user

Output consists of a success/failure flag, an HTTP response code, and a response body. The response body can be anything that is JSON encodable.

Properties

private $ok
private $code
private $message
private $appdata
private $metrics
private $debug

Methods

bool
isOK()

Returns whether or not the request succeeded

int
GetCode()

Returns the response code for the request

string
GetMessage()

Returns the error message string (only if not isOK)

GetAppdata()

Returns the response body to be returned (only if isOK)

SetMetrics(array|null $metrics)

Sets performance metrics to be returned

array
GetAsArray()

Returns the Output object as a client array

string|null
GetAsString()

Returns the appdata as a single string (or null if not possible)

__construct(bool $ok = true, int $code = 200)

No description

static Output
Success(array $appdata)

Constructs an Output object representing a success response

static Output
ClientException(ClientException $e, array|null $debug = null)

Constructs an Output object representing a client error, showing the exception and possibly extra debug

static Output
Exception(array|null $debug = null)

Constructs an Output object representing a non-client error, possibly with debug

static Output
ParseArray(array $data)

Parses a response from a remote Andromeda API request into an Output object

Details

at line 25
bool isOK()

Returns whether or not the request succeeded

Return Value

bool

at line 28
int GetCode()

Returns the response code for the request

Return Value

int

at line 31
string GetMessage()

Returns the error message string (only if not isOK)

Return Value

string

at line 34
GetAppdata()

Returns the response body to be returned (only if isOK)

at line 37
Output SetMetrics(array|null $metrics)

Sets performance metrics to be returned

Parameters

array|null $metrics

Return Value

Output

at line 44
array GetAsArray()

Returns the Output object as a client array

Return Value

array

if success: {ok:true, code:int, appdata:mixed} \ if failure: {ok:false, code:int, message:string}

at line 59
string|null GetAsString()

Returns the appdata as a single string (or null if not possible)

Return Value

string|null

at line 78
private __construct(bool $ok = true, int $code = 200)

No description

Parameters

bool $ok
int $code

at line 84
static Output Success(array $appdata)

Constructs an Output object representing a success response

Parameters

array $appdata

Return Value

Output

at line 93
static Output ClientException(ClientException $e, array|null $debug = null)

Constructs an Output object representing a client error, showing the exception and possibly extra debug

Parameters

ClientException $e
array|null $debug

Return Value

Output

at line 105
static Output Exception(array|null $debug = null)

Constructs an Output object representing a non-client error, possibly with debug

Parameters

array|null $debug

Return Value

Output

at line 122
static Output ParseArray(array $data)

Parses a response from a remote Andromeda API request into an Output object

Parameters

array $data

the response data from the remote request

Return Value

Output

the output object constructed from the response

Exceptions

InvalidParseException

if the response is malformed