MessageBag
class MessageBag implements ArrayableInterface, Countable, JsonableInterface, MessageProviderInterface, JsonSerializable (View source)
Properties
protected array | $messages | All of the registered messages. |
|
protected string | $format | Default format for message output. |
Methods
Create a new message bag instance.
Add a message to the bag.
Determine if a key and message combination already exists.
Determine if messages exist for a given key.
Get the first message from the bag for a given key.
Get all of the messages from the bag for a given key.
Get all of the messages for every key in the bag.
Format an array of messages.
Get the appropriate format based on the given format.
Get the raw messages in the container.
Get the messages for the instance.
Get the default message format.
Set the default message format.
Determine if the message bag has any messages.
Determine if the message bag has any messages.
Get the number of messages in the container.
Get the instance as an array.
Convert the object into something JSON serializable.
Convert the object to its JSON representation.
Convert the message bag to its string representation.
Details
void
__construct(array $messages = array())
Create a new message bag instance.
$this
add(string $key, string $message)
Add a message to the bag.
$this
merge(MessageProviderInterface|array $messages)
Merge a new array of messages into the bag.
protected bool
isUnique(string $key, string $message)
Determine if a key and message combination already exists.
bool
has(string $key = null)
Determine if messages exist for a given key.
string
first(string $key = null, string $format = null)
Get the first message from the bag for a given key.
array
get(string $key, string $format = null)
Get all of the messages from the bag for a given key.
array
all(string $format = null)
Get all of the messages for every key in the bag.
protected array
transform(array $messages, string $format, string $messageKey)
Format an array of messages.
protected string
checkFormat(string $format)
Get the appropriate format based on the given format.
array
getMessages()
Get the raw messages in the container.
MessageBag
getMessageBag()
Get the messages for the instance.
string
getFormat()
Get the default message format.
MessageBag
setFormat(string $format = ':message')
Set the default message format.
bool
isEmpty()
Determine if the message bag has any messages.
bool
any()
Determine if the message bag has any messages.
int
count()
Get the number of messages in the container.
array
toArray()
Get the instance as an array.
array
jsonSerialize()
Convert the object into something JSON serializable.
string
toJson(int $options = 0)
Convert the object to its JSON representation.
string
__toString()
Convert the message bag to its string representation.