File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,18 @@ public function ifNull()
9797 return $ this ;
9898 }
9999
100+ /**
101+ * Tests if the value is empty.
102+ *
103+ * @return ExprBuilder
104+ */
105+ public function ifEmpty ()
106+ {
107+ $ this ->ifPart = function ($ v ) { return empty ($ v ); };
108+
109+ return $ this ;
110+ }
111+
100112 /**
101113 * Tests if the value is an array.
102114 *
Original file line number Diff line number Diff line change @@ -75,6 +75,21 @@ public function testIfNullExpression()
7575 $ this ->assertFinalizedValueIs ('value ' , $ test );
7676 }
7777
78+ public function testIfEmptyExpression ()
79+ {
80+ $ test = $ this ->getTestBuilder ()
81+ ->ifEmpty ()
82+ ->then ($ this ->returnClosure ('new_value ' ))
83+ ->end ();
84+ $ this ->assertFinalizedValueIs ('new_value ' , $ test , array ('key ' => array ()));
85+
86+ $ test = $ this ->getTestBuilder ()
87+ ->ifEmpty ()
88+ ->then ($ this ->returnClosure ('new_value ' ))
89+ ->end ();
90+ $ this ->assertFinalizedValueIs ('value ' , $ test );
91+ }
92+
7893 public function testIfArrayExpression ()
7994 {
8095 $ test = $ this ->getTestBuilder ()
You can’t perform that action at this time.
0 commit comments