Invoker for Callable Classes & Methods
This can construct & call a method on a passed passed classname::method string., (*1)
This library is great for command bus, event bus or message bus processing, where by just passing a class name and method as a string can be instanciated and executed., (*2)
Usage & Examples
Construct
$invoker = new KodCube\Invoker\Invoker();
Callable Object
$invoker = new KodCube\Invoker\Invoker();
$result = $invoker('MyClass');
is the same as, (*3)
$class = new MyClass();
$result = $class();
Public Method on Object
$invoker = new KodCube\Invoker\Invoker();
$result = $invoker('MyClass::myMethod');
is the same as, (*4)
$class = new MyClass();
$result = $class->myMethod();
Public Method on Object with constructor arguments
$invoker = new KodCube\Invoker\Invoker();
$result = $invoker('MyClass::myMethod',null,['arg1','arg2']);
is the same as, (*5)
$class = new MyClass('arg1','arg2');
$result = $class->myMethod();
Public Method on Object with method arguments
$invoker = new KodCube\Invoker\Invoker();
$result = $invoker('MyClass::myMethod',['arg1','arg2']);
is the same as, (*6)
$class = new MyClass();
$result = $class->myMethod('arg1','arg2');
Public Static Method
$invoker = new KodCube\Invoker\Invoker();
$result = $invoker('MyClass::myMethod');
is the same as, (*7)
$result = MyClass::myMethod();