File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,19 @@ public function hasAny($keys = [])
159
159
return false ;
160
160
}
161
161
162
+ /**
163
+ * Determine if messages don't exist for all of the given keys.
164
+ *
165
+ * @param array|string|null $key
166
+ * @return bool
167
+ */
168
+ public function missing ($ key )
169
+ {
170
+ $ keys = is_array ($ key ) ? $ key : func_get_args ();
171
+
172
+ return ! $ this ->hasAny ($ keys );
173
+ }
174
+
162
175
/**
163
176
* Get the first message from the message bag for a given key.
164
177
*
Original file line number Diff line number Diff line change @@ -115,6 +115,19 @@ public function testHasIndicatesExistence()
115
115
$ this ->assertFalse ($ container ->has ('bar ' ));
116
116
}
117
117
118
+ public function testMissingIndicatesNonExistence ()
119
+ {
120
+ $ container = new MessageBag ;
121
+ $ container ->setFormat (':message ' );
122
+ $ container ->add ('foo ' , 'bar ' );
123
+ $ this ->assertFalse ($ container ->missing ('foo ' ));
124
+ $ this ->assertFalse ($ container ->missing (['foo ' , 'baz ' ]));
125
+ $ this ->assertFalse ($ container ->missing ('foo ' , 'baz ' ));
126
+ $ this ->assertTrue ($ container ->missing ('baz ' ));
127
+ $ this ->assertTrue ($ container ->missing (['baz ' , 'biz ' ]));
128
+ $ this ->assertTrue ($ container ->missing ('baz ' , 'biz ' ));
129
+ }
130
+
118
131
public function testAddIf ()
119
132
{
120
133
$ container = new MessageBag ;
You can’t perform that action at this time.
0 commit comments