OperationResult
in package
Class OperationResult
This class represents the result of an operation (ie. the result of a service's method), with a status and an optional list of messages.
Table of Contents
Properties
- $messages : array<string|int, TypedMessage>
- $success : bool
Methods
- __construct() : mixed
- addMessage() : mixed
- appendMessage() : mixed
- getMessages() : array<string|int, TypedMessage>
- Returns the messages of the given type, or all messages if no type is specified.
- getRawMessages() : array<string|int, string>
- Returns the raw messages of the given type, or all messages if no type is specified.
- isSuccess() : bool
- setMessages() : mixed
- setRawMessages() : mixed
- Sets messages from an array of strings
- setSuccess() : void
Properties
$messages
private
array<string|int, TypedMessage>
$messages
an array of messages providing extra details
$success
private
bool
$success
the basic result of the operation
Methods
__construct()
public
__construct([bool $success = false ][, array<string|int, TypedMessage>|TypedMessage $messages = [] ]) : mixed
Parameters
- $success : bool = false
- $messages : array<string|int, TypedMessage>|TypedMessage = []
addMessage()
public
addMessage(string $message, string $type) : mixed
Parameters
- $message : string
- $type : string
appendMessage()
public
appendMessage(TypedMessage $message) : mixed
Parameters
- $message : TypedMessage
getMessages()
Returns the messages of the given type, or all messages if no type is specified.
public
getMessages([string|null $type = null ]) : array<string|int, TypedMessage>
Parameters
- $type : string|null = null
Return values
array<string|int, TypedMessage>getRawMessages()
Returns the raw messages of the given type, or all messages if no type is specified.
public
getRawMessages([string|null $type = null ]) : array<string|int, string>
Parameters
- $type : string|null = null
Return values
array<string|int, string>isSuccess()
public
isSuccess() : bool
Return values
boolsetMessages()
public
setMessages(array<string|int, TypedMessage> $messages) : mixed
Parameters
- $messages : array<string|int, TypedMessage>
setRawMessages()
Sets messages from an array of strings
public
setRawMessages(array<string|int, string> $messages) : mixed
Parameters
- $messages : array<string|int, string>
setSuccess()
public
setSuccess(bool $success) : void
Parameters
- $success : bool