File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,17 @@ public function has($key)
66
66
return array_key_exists ($ key , $ this ->data );
67
67
}
68
68
69
+ /**
70
+ * Determine if the given key is missing.
71
+ *
72
+ * @param string $key
73
+ * @return bool
74
+ */
75
+ public function missing ($ key )
76
+ {
77
+ return ! $ this ->has ($ key );
78
+ }
79
+
69
80
/**
70
81
* Determine if the given key exists within the hidden context data.
71
82
*
@@ -77,6 +88,17 @@ public function hasHidden($key)
77
88
return array_key_exists ($ key , $ this ->hidden );
78
89
}
79
90
91
+ /**
92
+ * Determine if the given key is missing within the hidden context data.
93
+ *
94
+ * @param string $key
95
+ * @return bool
96
+ */
97
+ public function missingHidden ($ key )
98
+ {
99
+ return ! $ this ->hasHidden ($ key );
100
+ }
101
+
80
102
/**
81
103
* Retrieve all the context data.
82
104
*
Original file line number Diff line number Diff line change 4
4
5
5
/**
6
6
* @method static bool has(string $key)
7
+ * @method static bool missing(string $key)
7
8
* @method static bool hasHidden(string $key)
9
+ * @method static bool missingHidden(string $key)
8
10
* @method static array all()
9
11
* @method static array allHidden()
10
12
* @method static mixed get(string $key, mixed $default = null)
Original file line number Diff line number Diff line change @@ -263,6 +263,14 @@ public function test_it_can_check_if_context_has_been_set()
263
263
$ this ->assertFalse (Context::has ('unset ' ));
264
264
}
265
265
266
+ public function test_it_can_check_if_context_is_missing ()
267
+ {
268
+ Context::add ('foo ' , 'bar ' );
269
+
270
+ $ this ->assertTrue (Context::missing ('lorem ' ));
271
+ $ this ->assertFalse (Context::missing ('foo ' ));
272
+ }
273
+
266
274
public function test_it_can_check_if_value_is_in_context_stack ()
267
275
{
268
276
Context::push ('foo ' , 'bar ' , 'lorem ' );
You can’t perform that action at this time.
0 commit comments