There is a method called macro on a lot of built-in Laravel classes. For example Collection, Str, Arr, Request, Cache, File, and so on.
You can define your own methods on these classes like this:
1Str::macro('lowerSnake', function (string $str) {2 return Str::lower(Str::snake($str));3});4 5// Will return: "my-string"6Str::lowerSnake('MyString');
Tip given by @mmartin_joo