MessageBag.php 2.2 KB

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