We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 597f5ab commit a69479aCopy full SHA for a69479a
src/Illuminate/Support/Stringable.php
@@ -744,6 +744,23 @@ public function whenEmpty($callback)
744
return $this;
745
}
746
747
+ /**
748
+ * Execute the given callback if the string is not empty.
749
+ *
750
+ * @param callable $callback
751
+ * @return static
752
+ */
753
+ public function whenNotEmpty($callback)
754
+ {
755
+ if ($this->isNotEmpty()) {
756
+ $result = $callback($this);
757
+
758
+ return is_null($result) ? $this : $result;
759
+ }
760
761
+ return $this;
762
763
764
/**
765
* Limit the number of words in a string.
766
*
0 commit comments