Alright, following @calebporzio example I'm starting a podcast that is unscheduled thoughts in-between working on stuff. First episode is up now.
idlecursor.com/episodes/maybe-we-should-charge-for-mor
Matt Stenson
@mpstenson
I work as UserScape in php / laravel development and devops. Recreationally, a skier, mountain biker and general mountain person.
• • 6 Posts • 49 Views
Phone scan! Can't lie though, I'm in Canada and I scanned the photo of your phone :-)
Have a great Laracon!
I was recently working on a project where I wanted to make a classes functions available inside of the built in Laravel Str:: helper. Laravel Macros are the answer to this issue. However, I wanted to make adding additional methods an easy experience and needing to write and maintain a separate macro with argument definitions for each function was clunky.
foreach (get_class_methods(AdvStr::class) as $methodName) {
Str::macro($methodName, function () use ($methodName) {
$args = func_get_args();
return (new AdvStr())->$methodName(...$args);
});
explanation -> mattstenson.com/dynamically-macro-a-class-to-a-laravel-macroable-class