class JSON implements ResponseBuilderInterface

JSON builder.

Properties

protected mixed $data Data.
protected int $options JSON encode options.
protected string $callback Callback.
protected int $status Status code.

Methods

__construct(mixed $data, int $options = 0)

Constructor.

asJsonpWith(string $callback)

Enables JSONP support.

status(int $status)

Sets the status code.

string
normalizeCallback(string $callback)

Ensures a valid callback name.

build(Request $request, Response $response)

Builds the response.

Details

at line 57
__construct(mixed $data, int $options = 0)

Constructor.

Parameters

mixed $data Data
int $options JSON encode options

at line 70
JSON asJsonpWith(string $callback)

Enables JSONP support.

Parameters

string $callback Query string field

Return Value

JSON

at line 83
JSON status(int $status)

Sets the status code.

Parameters

int $status Status code

Return Value

JSON

at line 96
protected string normalizeCallback(string $callback)

Ensures a valid callback name.

Parameters

string $callback Callback name

Return Value

string

at line 109
build(Request $request, Response $response)

Builds the response.

Parameters

Request $request Request instance
Response $response Response instance