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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners