MessageBag
- Full name:
\Qubus\Validation\MessageBag
- This class implements:
\Countable
,\JsonSerializable
Properties
messages
All the registered messages.
format
Default format for message output.
Methods
__construct
Create a new message bag instance.
Parameters:
Parameter | Type | Description |
---|---|---|
$messages | array |
add
Add a message to the bag.
Parameters:
Parameter | Type | Description |
---|---|---|
$key | string | |
$message | string |
merge
Merge a new array of messages into the bag.
Parameters:
Parameter | Type | Description |
---|---|---|
$messages | array |
isUnique
Determine if a key and message combination already exists.
Parameters:
Parameter | Type | Description |
---|---|---|
$key | string | |
$message | string |
has
Determine if messages exist for a given key.
Parameters:
Parameter | Type | Description |
---|---|---|
$key | ?string |
first
Get the first message from the bag for a given key.
Parameters:
Parameter | Type | Description |
---|---|---|
$key | ?string | |
$format | ?string |
get
Get all the messages from the bag for a given key.
Parameters:
Parameter | Type | Description |
---|---|---|
$key | string|null | |
$format | string|null |
all
Get all the messages for every key in the bag.
Parameters:
Parameter | Type | Description |
---|---|---|
$format | string|null |
transform
Format an array of messages.
Parameters:
Parameter | Type | Description |
---|---|---|
$messages | array | |
$format | string | |
$messageKey | string |
checkFormat
Get the appropriate format based on the given format.
Parameters:
Parameter | Type | Description |
---|---|---|
$format | ?string |
getMessageBag
Get the messages for the instance.
getFormat
Get the default message format.
setFormat
Set the default message format.
Parameters:
Parameter | Type | Description |
---|---|---|
$format | string |
isEmpty
Determine if the message bag has any messages.
any
Determine if the message bag has any messages.
count
Get the number of messages in the container.
toArray
Get the instance as an array.
jsonSerialize
Convert the object into something JSON serializable.
toJson
Convert the object to its JSON representation.
Parameters:
Parameter | Type | Description |
---|---|---|
$options | int |
__toString
Convert the message bag to its string representation.
Automatically generated on 2025-10-13