If you’ve ever been in a situation where you need to wrap your string with some characters, let’s say ", you most probably would do something like so. '"'; As you can tell, you’ll need to concatenate the string with the characters that you want to wrap the string with. Now, at first, this kind of looks viable but think about the scenario where you’re building a string using Laravel’s fluent method like so. use Illuminate\Support\Str; $input = 'hello world!'; $output = Str::of($input) ->replace('world', 'universe') ->camel(); ..And if you want to wrap this line with inverted commas (“), you can’t just do that fluently.

$input = 'hello world!'; $output = Str::of($input) ->replace('world', 'universe') ->ucfirst() ->wrap('"'); // outputs: "Hello universe!"
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners