New package by the folks from Spatie:
We recently released our newest package called macroable. It contains a trait that, when applied to class, can dynamically add methods to that class. This trait is basically a stand alone version of the macroable trait in Laravel.
It works by leveraging the __call()
magic function, and checking if any macro has been registered via the static macro
method.
A trait to dynamically add methods to a class →spatie/macroable
(GitHub) →