class Response (View source)

A CLI specific response implementation

Constants

STYLE_BRIGHT

Constants for output styles

STYLE_FAINT

STYLE_ITALIC

STYLE_UNDERLINED

STYLE_INVERSE

STYLE_STRIKETHROUGH

STYLE_ERROR

STYLE_SUCCESS

OUTPUTFORMAT_RAW

Constants for output formats

OUTPUTFORMAT_PLAIN

OUTPUTFORMAT_STYLED

Methods

void
setExitCode(int $exitCode)

Sets the numerical exit code which should be returned when exiting this application.

int
getExitCode()

Gets the numerical exit code which should be returned when exiting this application.

void
setContent(string $content)

Overrides and sets the content of the response

void
appendContent(string $content)

Appends content to the already existing content.

string
getContent()

Returns the response content without sending it.

void
setColorSupport(bool $colorSupport)

Sets color support / styled output to yes, no or auto detection

bool
hasColorSupport()

Tells if the response content should be styled on send().

void
setOutputFormat(int $outputFormat)

Sets the desired output format.

int
getOutputFormat()

Returns the currently set output format.

void
send()

Sends the response

Details

void setExitCode(int $exitCode)

Sets the numerical exit code which should be returned when exiting this application.

Parameters

int $exitCode

Return Value

void

Exceptions

InvalidArgumentException

int getExitCode()

Gets the numerical exit code which should be returned when exiting this application.

Return Value

int

void setContent(string $content)

Overrides and sets the content of the response

Parameters

string $content

The response content

Return Value

void

void appendContent(string $content)

Appends content to the already existing content.

Parameters

string $content

More response content

Return Value

void

string getContent()

Returns the response content without sending it.

Return Value

string

The response content

void setColorSupport(bool $colorSupport)

Sets color support / styled output to yes, no or auto detection

Parameters

bool $colorSupport

true, false or NULL (= autodetection)

Return Value

void

bool hasColorSupport()

Tells if the response content should be styled on send().

Regardless of this setting content will only be styled with output format set to "styled".

Return Value

bool

true if the terminal support ANSI colors, otherwise false

void setOutputFormat(int $outputFormat)

Sets the desired output format.

Parameters

int $outputFormat

One of the OUTPUTFORMAT_* constants

Return Value

void

int getOutputFormat()

Returns the currently set output format.

Return Value

int

One of the OUTPUTFORMAT_* constants

void send()

Sends the response

Return Value

void