/** * Parses given command, creates new class object and calls its method via call_user_func_array * @param string $command * @return mixed */ public static function parseAndRunCommand($command) { try { list($class, $method, $args) = TaskManager::parseCommand($command); if (!class_exists($class)) { TaskLoader::loadController($class); } $obj = new $class(); if (!method_exists($obj, $method)) { throw new TaskManagerException('method ' . $method . ' not found in class ' . $class); } return call_user_func_array(array($obj, $method), $args); } catch (\Exception $e) { echo 'Caught an exception: ' . get_class($e) . ': ' . PHP_EOL . $e->getMessage() . PHP_EOL; return false; } }
public function testLoadControllerExceptions() { $this->setExpectedException('mult1mate\\crontab\\TaskManagerException'); TaskLoader::setClassFolder(__DIR__); TaskLoader::loadController('MockClass'); }