Skip to content

Conversation

@Gummibeer
Copy link
Contributor

This PR adds a \Illuminate\Support\Stringable::whenNotEmpty() method which is the inversion of the already existing whenEmpty() method.
This is useful if you want to handle something like prefixes - for example if the prefix isn't empty it should be finished with an underscore. Right now this isn't easily possible - with the whenNotEmpty() you can finish the prefix if it has a value and if not the prefix will remain empty.

Str::of(env('SCOUT_PREFIX', '')) ->whenNotEmpty(fn (Stringable $prefix) => $prefix->finish('_'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants