Aids collation of error messages, and helps test whether errors exist.
Simple wrapper around an array.
Typically useful for processing user input errors.
Example:
$errobj = new ProjectError;
if ($validuserinput == false) {
$errobj->addError('Your input is invalid');
}
if (!$errobj->isErrors()) {
//do stuff
} else {
$errorsoutput = Format::asMessage($errobj->getErrors);
}
Works well with Format::asMessage() which can output a CSS formated 'error list'.
package | dstruct_common |
---|
addError(string $error) : boolean
Fails if there is no actual error to add, which avoids empty error strings being displayed to users (e.g. when using FileUploader it is easy to introduce a 'non-error'
string
boolean
false if $error evaluates to false and no error is addedclear()
count() : integer
integer
getErrors() : array
array
isErrors() : boolean
boolean
$errors : array