Documentation

HasError

A trait for application classes to use which provides a couple methods for handling errors and displaying error messages.

Table of Contents

error()  : mixed
A method to display an error message along with a quick note about how to get further help information.
stderr()  : int
A small wrapper method to write a string to STDERR.
getParamsInstance()  : mixed
This must be consumed by a class that has a getParamsInstance() method which must return the initialized copy of the Params instance.

Methods

error()

A method to display an error message along with a quick note about how to get further help information.

public error(string $errmsg[, int $errcode = 1 ]) : mixed
Parameters
$errmsg : string

The error message to write to STDERR.

$errcode : int = 1

The error code to exit the app with (default: 1)

Not sure why you'd want to do this, but if the $errcode is less than 0 or greater than 254, the exit() statement will not be called at all.

Note this requires a class instance property to exist called 'usage_message' which will be a template with the help placeholder, which by default is {help} which will be replaced with the appropriate usage command line parameter.

Return values
mixed

stderr()

A small wrapper method to write a string to STDERR.

public static stderr(string $message) : int
Parameters
$message : string

The message to write to STDERR.

Return values
int

The number of bytes written, or false on error.

getParamsInstance()

This must be consumed by a class that has a getParamsInstance() method which must return the initialized copy of the Params instance.

protected abstract getParamsInstance() : mixed
Return values
mixed

Search results