Laravel ships with a good number of laravel helpers, which not only make the job easy but also make the code clean and more readable. Two of those laravel helpers are
- filled: bool
- blank: bool
As the name suggests, they check if the string is filled or blank and returns a bool.
$string = "";
filled($string); // false
blank($string); // true
The limitation of these helpers was, that they were not supported by the Stringable
. So, if we created a string with a Stringable method (str()) it won't work because the str
method returns a stringable object rather than the string itself.
But thanks to Stefan R., in his contribution made the update.
Here is the link to PR
filled(str('FooBar ')); //true
blank(str(' ')); //true