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:
Str::macro('lowerSnake', function (string $str) { return Str::lower(Str::snake($str));}); // Will return: "my-string"Str::lowerSnake('MyString');
Tip given by @mmartin_joo