File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,17 @@ public function has($key)
69
69
return array_key_exists ($ key , $ this ->attributes );
70
70
}
71
71
72
+ /**
73
+ * Determine if a given attribute is missing from the attribute array.
74
+ *
75
+ * @param string $key
76
+ * @return bool
77
+ */
78
+ public function missing ($ key )
79
+ {
80
+ return ! $ this ->has ($ key , $ this ->attributes );
81
+ }
82
+
72
83
/**
73
84
* Only include the given attribute from the attribute array.
74
85
*
Original file line number Diff line number Diff line change @@ -94,4 +94,14 @@ public function testAttributeRetrieval()
94
94
'test-extract-2 ' => 'defaultValue ' ,
95
95
]));
96
96
}
97
+
98
+ public function testAttibuteExistence ()
99
+ {
100
+ $ bag = new ComponentAttributeBag (['name ' => 'test ' ]);
101
+
102
+ $ this ->assertTrue ((bool ) $ bag ->has ('name ' ));
103
+ $ this ->assertFalse ((bool ) $ bag ->missing ('name ' ));
104
+ $ this ->assertFalse ((bool ) $ bag ->has ('class ' ));
105
+ $ this ->assertTrue ((bool ) $ bag ->missing ('class ' ));
106
+ }
97
107
}
You can’t perform that action at this time.
0 commit comments