MessageBag
in package
implements
Arrayable, Countable, Jsonable, JsonSerializable, MessageBag, MessageProvider
Interfaces, Classes and Traits
Table of Contents
- $format : string
- Default format for message output.
- $messages : array<string|int, mixed>
- All of the registered messages.
- __construct() : void
- Create a new message bag instance.
- __toString() : string
- Convert the message bag to its string representation.
- add() : $this
- Add a message to the bag.
- all() : array<string|int, mixed>
- Get all of the messages for every key in the bag.
- any() : bool
- Determine if the message bag has any messages.
- count() : int
- Get the number of messages in the container.
- first() : string
- Get the first message from the bag for a given key.
- get() : array<string|int, mixed>
- Get all of the messages from the bag for a given key.
- getFormat() : string
- Get the default message format.
- getMessageBag() : MessageBag
- Get the messages for the instance.
- getMessages() : array<string|int, mixed>
- Get the raw messages in the container.
- has() : bool
- Determine if messages exist for all of the given keys.
- hasAny() : bool
- Determine if messages exist for any of the given keys.
- isEmpty() : bool
- Determine if the message bag has any messages.
- isNotEmpty() : bool
- Determine if the message bag has any messages.
- jsonSerialize() : array<string|int, mixed>
- Convert the object into something JSON serializable.
- keys() : array<string|int, mixed>
- Get the keys present in the message bag.
- merge() : $this
- Merge a new array of messages into the bag.
- messages() : array<string|int, mixed>
- Get the raw messages in the container.
- setFormat() : MessageBag
- Set the default message format.
- toArray() : array<string|int, mixed>
- Get the instance as an array.
- toJson() : string
- Convert the object to its JSON representation.
- unique() : array<string|int, mixed>
- Get all of the unique messages for every key in the bag.
- checkFormat() : string
- Get the appropriate format based on the given format.
- getMessagesForWildcardKey() : array<string|int, mixed>
- Get the messages for a wildcard key.
- isUnique() : bool
- Determine if a key and message combination already exists.
- transform() : array<string|int, mixed>
- Format an array of messages.
Properties
$format
Default format for message output.
protected
string
$format
= ':message'
$messages
All of the registered messages.
protected
array<string|int, mixed>
$messages
= []
Methods
__construct()
Create a new message bag instance.
public
__construct([array<string|int, mixed> $messages = [] ]) : void
Parameters
- $messages : array<string|int, mixed> = []
Return values
void —__toString()
Convert the message bag to its string representation.
public
__toString() : string
Return values
string —add()
Add a message to the bag.
public
add(string $key, string $message) : $this
Parameters
- $key : string
- $message : string
Return values
$this —all()
Get all of the messages for every key in the bag.
public
all([string $format = null ]) : array<string|int, mixed>
Parameters
- $format : string = null
Return values
array<string|int, mixed> —any()
Determine if the message bag has any messages.
public
any() : bool
Return values
bool —count()
Get the number of messages in the container.
public
count() : int
Return values
int —first()
Get the first message from the bag for a given key.
public
first([string $key = null ][, string $format = null ]) : string
Parameters
- $key : string = null
- $format : string = null
Return values
string —get()
Get all of the messages from the bag for a given key.
public
get(string $key[, string $format = null ]) : array<string|int, mixed>
Parameters
- $key : string
- $format : string = null
Return values
array<string|int, mixed> —getFormat()
Get the default message format.
public
getFormat() : string
Return values
string —getMessageBag()
Get the messages for the instance.
public
getMessageBag() : MessageBag
Return values
MessageBag —getMessages()
Get the raw messages in the container.
public
getMessages() : array<string|int, mixed>
Return values
array<string|int, mixed> —has()
Determine if messages exist for all of the given keys.
public
has(array<string|int, mixed>|string $key) : bool
Parameters
- $key : array<string|int, mixed>|string
Return values
bool —hasAny()
Determine if messages exist for any of the given keys.
public
hasAny([array<string|int, mixed>|string $keys = [] ]) : bool
Parameters
- $keys : array<string|int, mixed>|string = []
Return values
bool —isEmpty()
Determine if the message bag has any messages.
public
isEmpty() : bool
Return values
bool —isNotEmpty()
Determine if the message bag has any messages.
public
isNotEmpty() : bool
Return values
bool —jsonSerialize()
Convert the object into something JSON serializable.
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —keys()
Get the keys present in the message bag.
public
keys() : array<string|int, mixed>
Return values
array<string|int, mixed> —merge()
Merge a new array of messages into the bag.
public
merge(MessageProvider|array<string|int, mixed> $messages) : $this
Parameters
- $messages : MessageProvider|array<string|int, mixed>
Return values
$this —messages()
Get the raw messages in the container.
public
messages() : array<string|int, mixed>
Return values
array<string|int, mixed> —setFormat()
Set the default message format.
public
setFormat([string $format = ':message' ]) : MessageBag
Parameters
- $format : string = ':message'
Return values
MessageBag —toArray()
Get the instance as an array.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —toJson()
Convert the object to its JSON representation.
public
toJson(int $options) : string
Parameters
- $options : int
Return values
string —unique()
Get all of the unique messages for every key in the bag.
public
unique([string $format = null ]) : array<string|int, mixed>
Parameters
- $format : string = null
Return values
array<string|int, mixed> —checkFormat()
Get the appropriate format based on the given format.
protected
checkFormat(string $format) : string
Parameters
- $format : string
Return values
string —getMessagesForWildcardKey()
Get the messages for a wildcard key.
protected
getMessagesForWildcardKey(string $key, string|null $format) : array<string|int, mixed>
Parameters
- $key : string
- $format : string|null
Return values
array<string|int, mixed> —isUnique()
Determine if a key and message combination already exists.
protected
isUnique(string $key, string $message) : bool
Parameters
- $key : string
- $message : string
Return values
bool —transform()
Format an array of messages.
protected
transform(array<string|int, mixed> $messages, string $format, string $messageKey) : array<string|int, mixed>
Parameters
- $messages : array<string|int, mixed>
- $format : string
- $messageKey : string