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

 Methods

Add an error.

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'

Parameters

$error

string

Returns

booleanfalse if $error evaluates to false and no error is added

Clears any errors stored in the object.

clear() 

The current number of errors.

count() : integer

Returns

integer

(non-PHPdoc)

current() 

Get any errors stored in the object.

getErrors() : array

Returns

array

Are any errors stored in the object?

isErrors() : boolean

Returns

boolean

(non-PHPdoc)

key() 

(non-PHPdoc)

next() 

(non-PHPdoc)

rewind() 

(non-PHPdoc)

valid() 

 Properties

 

$errors : array