class ProcessResult implements ProcessResult (View source)

Properties

protected Process $process

The underlying process instance.

Methods

void
__construct(Process $process)

Create a new process result instance.

string
command()

Get the original command executed by the process.

bool
successful()

Determine if the process was successful.

bool
failed()

Determine if the process failed.

int|null
exitCode()

Get the exit code of the process.

string
output()

Get the standard output of the process.

bool
seeInOutput(string $output)

Determine if the output contains the given string.

string
errorOutput()

Get the error output of the process.

bool
seeInErrorOutput(string $output)

Determine if the error output contains the given string.

$this
throw(callable|null $callback = null)

Throw an exception if the process failed.

$this
throwIf(bool $condition, callable|null $callback = null)

Throw an exception if the process failed and the given condition is true.

Details

void __construct(Process $process)

Create a new process result instance.

Parameters

Process $process

Return Value

void

string command()

Get the original command executed by the process.

Return Value

string

bool successful()

Determine if the process was successful.

Return Value

bool

bool failed()

Determine if the process failed.

Return Value

bool

int|null exitCode()

Get the exit code of the process.

Return Value

int|null

string output()

Get the standard output of the process.

Return Value

string

bool seeInOutput(string $output)

Determine if the output contains the given string.

Parameters

string $output

Return Value

bool

string errorOutput()

Get the error output of the process.

Return Value

string

bool seeInErrorOutput(string $output)

Determine if the error output contains the given string.

Parameters

string $output

Return Value

bool

$this throw(callable|null $callback = null)

Throw an exception if the process failed.

Parameters

callable|null $callback

Return Value

$this

Exceptions

ProcessFailedException

$this throwIf(bool $condition, callable|null $callback = null)

Throw an exception if the process failed and the given condition is true.

Parameters

bool $condition
callable|null $callback

Return Value

$this

Exceptions

Throwable