PHP Class Overtrue\Validation\MessageBag

Inheritance: implements Countabl\Countable, implements JsonSerializabl\JsonSerializable
Afficher le fichier Open project: overtrue/validation Class Usage Examples

Protected Properties

Свойство Type Description
$format string Default format for message output.
$messages array All of the registered messages.

Méthodes publiques

Méthode Description
__construct ( array $messages = [] ) : MessageBag Create a new message bag instance.
__toString ( ) : string Convert the message bag to its string representation.
add ( string $key, string $message ) Add a message to the bag.
all ( string $format = null ) : array Get all of the messages for every key in the bag.
any ( ) : boolean Determine if the message bag has any messages.
count ( ) : integer Get the number of messages in the container.
first ( string $key = null, string $format = null ) : string Get the first message from the bag for a given key.
get ( string $key, string $format = null ) : array 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 Get the raw messages in the container.
has ( string $key = null ) : boolean Determine if messages exist for a given key.
isEmpty ( ) : boolean Determine if the message bag has any messages.
jsonSerialize ( ) : array Convert the object into something JSON serializable.
merge ( array $messages ) Merge a new array of messages into the bag.
setFormat ( string $format = ':message' ) : MessageBag Set the default message format.
toArray ( ) : array Get the instance as an array.
toJson ( integer $options ) : string Convert the object to its JSON representation.

Méthodes protégées

Méthode Description
checkFormat ( string $format ) : string Get the appropriate format based on the given format.
isUnique ( string $key, string $message ) : boolean Determine if a key and message combination already exists.
transform ( array $messages, string $format, string $messageKey ) : array Format an array of messages.

Method Details

__construct() public méthode

Create a new message bag instance.
public __construct ( array $messages = [] ) : MessageBag
$messages array
Résultat MessageBag

__toString() public méthode

Convert the message bag to its string representation.
public __toString ( ) : string
Résultat string

add() public méthode

Add a message to the bag.
public add ( string $key, string $message )
$key string
$message string

all() public méthode

Get all of the messages for every key in the bag.
public all ( string $format = null ) : array
$format string
Résultat array

any() public méthode

Determine if the message bag has any messages.
public any ( ) : boolean
Résultat boolean

checkFormat() protected méthode

Get the appropriate format based on the given format.
protected checkFormat ( string $format ) : string
$format string
Résultat string

count() public méthode

Get the number of messages in the container.
public count ( ) : integer
Résultat integer

first() public méthode

Get the first message from the bag for a given key.
public first ( string $key = null, string $format = null ) : string
$key string
$format string
Résultat string

get() public méthode

Get all of the messages from the bag for a given key.
public get ( string $key, string $format = null ) : array
$key string
$format string
Résultat array

getFormat() public méthode

Get the default message format.
public getFormat ( ) : string
Résultat string

getMessageBag() public méthode

Get the messages for the instance.
public getMessageBag ( ) : MessageBag
Résultat MessageBag

getMessages() public méthode

Get the raw messages in the container.
public getMessages ( ) : array
Résultat array

has() public méthode

Determine if messages exist for a given key.
public has ( string $key = null ) : boolean
$key string
Résultat boolean

isEmpty() public méthode

Determine if the message bag has any messages.
public isEmpty ( ) : boolean
Résultat boolean

isUnique() protected méthode

Determine if a key and message combination already exists.
protected isUnique ( string $key, string $message ) : boolean
$key string
$message string
Résultat boolean

jsonSerialize() public méthode

Convert the object into something JSON serializable.
public jsonSerialize ( ) : array
Résultat array

merge() public méthode

Merge a new array of messages into the bag.
public merge ( array $messages )
$messages array

setFormat() public méthode

Set the default message format.
public setFormat ( string $format = ':message' ) : MessageBag
$format string
Résultat MessageBag

toArray() public méthode

Get the instance as an array.
public toArray ( ) : array
Résultat array

toJson() public méthode

Convert the object to its JSON representation.
public toJson ( integer $options ) : string
$options integer
Résultat string

transform() protected méthode

Format an array of messages.
protected transform ( array $messages, string $format, string $messageKey ) : array
$messages array
$format string
$messageKey string
Résultat array

Property Details

$format protected_oe property

Default format for message output.
protected string $format
Résultat string

$messages protected_oe property

All of the registered messages.
protected array $messages
Résultat array