Errors
Errors trait
Table of Contents
Properties
- $errors : array<string|int, mixed>
- Errors list
- $validationErrorMessages : array<string|int, mixed>
- Validation error messages
Methods
- addError() : void
- Add system error
- addErrors() : void
- Add errors
- clearErrors() : void
- Clear all errors.
- error() : self
- Set error, first find in messages array if not found display name value as error
- getError() : string
- Get error
- getErrorCount() : int
- Return errors count
- hasError() : bool
- Return true if response have error
- setError() : void
- Set error message
- setErrors() : void
- Set errors
- withError() : self
- Set error message
- getValidationErrorMessage() : string|null
- Get validaiton error message
- resolveValidationErrors() : array<string|int, mixed>
- Resolve validation errors
Properties
$errors
Errors list
protected
array<string|int, mixed>
$errors
= []
$validationErrorMessages
Validation error messages
protected
array<string|int, mixed>
$validationErrorMessages
= []
Methods
addError()
Add system error
public
addError(string $errorCode) : void
Parameters
- $errorCode : string
addErrors()
Add errors
public
addErrors(array<string|int, mixed> $errors) : void
Parameters
- $errors : array<string|int, mixed>
clearErrors()
Clear all errors.
public
clearErrors() : void
error()
Set error, first find in messages array if not found display name value as error
public
error(string $name[, string|null $default = null ]) : self
Parameters
- $name : string
- $default : string|null = null
Return values
selfgetError()
Get error
public
getError(string $errorCode) : string
Parameters
- $errorCode : string
Return values
stringgetErrorCount()
Return errors count
public
getErrorCount() : int
Return values
inthasError()
Return true if response have error
public
hasError() : bool
Return values
boolsetError()
Set error message
public
setError(string $errorMessage[, bool $condition = true ]) : void
Parameters
- $errorMessage : string
- $condition : bool = true
setErrors()
Set errors
public
setErrors(array<string|int, mixed> $errors) : void
Parameters
- $errors : array<string|int, mixed>
withError()
Set error message
public
withError(string $errorMessage[, bool $condition = true ]) : self
Parameters
- $errorMessage : string
- $condition : bool = true
Return values
selfgetValidationErrorMessage()
Get validaiton error message
protected
getValidationErrorMessage(string $code) : string|null
Parameters
- $code : string
Return values
string|nullresolveValidationErrors()
Resolve validation errors
protected
resolveValidationErrors(array<string|int, mixed> $errors) : array<string|int, mixed>
Parameters
- $errors : array<string|int, mixed>