laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

Add Str::isNullOrEmpty #2543

Closed nessor closed 3 years ago

nessor commented 3 years ago

Would it perhaps be helpful to add a method isNullOrEmpty for the string helpers? The implementation would be very simple. Maybe like this:

public static function isNullOrEmpty($str){
    return (!isset($str) || trim($str) === '');
}

What do you guys think?

tpetry commented 3 years ago

The blank() helper is doing exactly what you are searching for.

nessor commented 3 years ago

Oh boi. That's nice! nvm

BTW: Why isn't there a static method for this?

tpetry commented 3 years ago

Because it's not limited to strings, you can pass in arrays, numbers and booleans too.