MessageBag.php 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace Illuminate\Contracts\Support;
  3. interface MessageBag extends Arrayable
  4. {
  5. /**
  6. * Get the keys present in the message bag.
  7. *
  8. * @return array
  9. */
  10. public function keys();
  11. /**
  12. * Add a message to the bag.
  13. *
  14. * @param string $key
  15. * @param string $message
  16. * @return $this
  17. */
  18. public function add($key, $message);
  19. /**
  20. * Merge a new array of messages into the bag.
  21. *
  22. * @param \Illuminate\Contracts\Support\MessageProvider|array $messages
  23. * @return $this
  24. */
  25. public function merge($messages);
  26. /**
  27. * Determine if messages exist for a given key.
  28. *
  29. * @param string|array $key
  30. * @return bool
  31. */
  32. public function has($key);
  33. /**
  34. * Get the first message from the bag for a given key.
  35. *
  36. * @param string $key
  37. * @param string $format
  38. * @return string
  39. */
  40. public function first($key = null, $format = null);
  41. /**
  42. * Get all of the messages from the bag for a given key.
  43. *
  44. * @param string $key
  45. * @param string $format
  46. * @return array
  47. */
  48. public function get($key, $format = null);
  49. /**
  50. * Get all of the messages for every key in the bag.
  51. *
  52. * @param string $format
  53. * @return array
  54. */
  55. public function all($format = null);
  56. /**
  57. * Get the raw messages in the container.
  58. *
  59. * @return array
  60. */
  61. public function getMessages();
  62. /**
  63. * Get the default message format.
  64. *
  65. * @return string
  66. */
  67. public function getFormat();
  68. /**
  69. * Set the default message format.
  70. *
  71. * @param string $format
  72. * @return $this
  73. */
  74. public function setFormat($format = ':message');
  75. /**
  76. * Determine if the message bag has any messages.
  77. *
  78. * @return bool
  79. */
  80. public function isEmpty();
  81. /**
  82. * Determine if the message bag has any messages.
  83. *
  84. * @return bool
  85. */
  86. public function isNotEmpty();
  87. /**
  88. * Get the number of messages in the container.
  89. *
  90. * @return int
  91. */
  92. public function count();
  93. }