I am building an API where the user requests a \'command\', which is passed into a class. Assuming the command matches a PUBLIC function, it will execute successfully. If th
Simply use ReflectionMethod:
/**
* Look for Command method
*/
if (method_exists($this, $sMethod))
{
$reflection = new ReflectionMethod($this, $sMethod);
if (!$reflection->isPublic()) {
throw new RuntimeException("The called method is not public.");
}
/**
* Run the command
*/
return $this->$sMethod($aParameters);
}