class CommandResult implements ExitCodeInterface, OutputDataInterface (View source)

Return a CommandResult as the result of a command to pass both an exit code and result data from a command.

Usage:

 return CommandResult::dataWithExitCode(new RowsOfFields($rows), 1);

The CommandResult can also be used to unambiguously return just an exit code or just output data.

Exit code only:

 return CommandResult::dataWithExitCode(1);

Data only:

 return CommandResult::data(new RowsOfFields($rows));

Historically, it has always been possible to return an integer to indicate that the result is an exit code, and other return types (typically array / ArrayObjects) indicating actual data with an implicit exit code of 0. Using a CommandResult is preferred, though, as it allows the result of the function to be unambiguously specified without type-based interpretation.

Properties

protected $data
protected $exitCode

Methods

__construct($data = null, $exitCode = 0)

No description

static 
exitCode($exitCode)

No description

static 
data($data)

No description

static 
dataWithExitCode($data, $exitCode)

No description

getExitCode()

No description

getOutputData()

No description

setOutputData($data)

No description

Details

protected __construct($data = null, $exitCode = 0)

No description

Parameters

$data
$exitCode

static exitCode($exitCode)

No description

Parameters

$exitCode

static data($data)

No description

Parameters

$data

static dataWithExitCode($data, $exitCode)

No description

Parameters

$data
$exitCode

getExitCode()

No description

getOutputData()

No description

setOutputData($data)

No description

Parameters

$data