About
This is a library that can be used to call functions, closures(AKA: anonymous functions), classes and methods. It can be used for calling dynamic values, say a handler in an HTTP router. Or containers.
Installation
You can install this via composer, or manually download the files.
composer require fobber/caller
Caller Documentation
\Fobber\Caller\Caller::callClosure(
\Closure $closure,
array $parameters = []
);
\Fobber\Caller\Caller::callFunction(
string $function,
array $parameters = []
);
\Fobber\Caller\Caller::callClass(
string $class,
array $parameters = []
);
\Fobber\Caller\Caller::callMethod(
object $object,
string $method,
array $parameters = [],
bool $static_only = false
);
Caller Basic Usage
require_once __DIR__.'/path/to/autoload.php';
use \Fobber\Caller\{
Validator,
Caller
};
use \Fobber\Exceptions\{
InvalidFunctionException,
InvalidClassException,
InvalidMethodException
};
$validator = new Validator;
$caller = new Caller($validator);
Calling Closures
$value = $caller->
…