File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,26 @@ public function toJson($options = 0)
203203 return json_encode ($ this ->jsonSerialize (), $ options );
204204 }
205205
206+ /**
207+ * Determine if the fluent instance is empty.
208+ *
209+ * @return bool
210+ */
211+ public function isEmpty (): bool
212+ {
213+ return empty ($ this ->attributes );
214+ }
215+
216+ /**
217+ * Determine if the fluent instance is not empty.
218+ *
219+ * @return bool
220+ */
221+ public function isNotEmpty (): bool
222+ {
223+ return ! $ this ->isEmpty ();
224+ }
225+
206226 /**
207227 * Determine if the given offset exists.
208228 *
Original file line number Diff line number Diff line change @@ -471,6 +471,25 @@ public function testFluentIsIterable()
471471 'role ' => 'admin ' ,
472472 ], $ result );
473473 }
474+
475+ public function testFluentIsEmpty ()
476+ {
477+ $ fluent = new Fluent ;
478+
479+ $ this ->assertTrue ($ fluent ->isEmpty ());
480+ $ this ->assertFalse ($ fluent ->isNotEmpty ());
481+ }
482+
483+ public function testFluentIsNotEmpty ()
484+ {
485+ $ fluent = new Fluent ([
486+ 'name ' => 'Taylor ' ,
487+ 'role ' => 'admin ' ,
488+ ]);
489+
490+ $ this ->assertTrue ($ fluent ->isNotEmpty ());
491+ $ this ->assertFalse ($ fluent ->isEmpty ());
492+ }
474493}
475494
476495class FluentArrayIteratorStub implements IteratorAggregate
You can’t perform that action at this time.
0 commit comments