diff --git a/flight/Engine.php b/flight/Engine.php index 914e08e..8c0c41a 100644 --- a/flight/Engine.php +++ b/flight/Engine.php @@ -272,6 +272,16 @@ class Engine { $this->loader->addDirectory($dir); } + /** + * Checks for mapped event within the engine dispatcher. + * + * @param $name + * @return bool + */ + public function isEvent($name) { + return !is_null($this->dispatcher->get($name)); + } + /*** Extensible Methods ***/ /** diff --git a/flight/Flight.php b/flight/Flight.php index f58dc2c..c2de4f9 100644 --- a/flight/Flight.php +++ b/flight/Flight.php @@ -69,15 +69,20 @@ class Flight { * @param string $name Method name * @param array $params Method parameters * @return mixed Callback results + * @throws \Exception */ public static function __callStatic($name, $params) { $app = Flight::app(); + if (!method_exists($app, $name) && !$app->isEvent($name)) { + throw new \Exception("{$name} must be a mapped method"); + } + return \flight\core\Dispatcher::invokeMethod(array($app, $name), $params); } /** - * @return object Application instance + * @return \flight\Engine Application instance */ public static function app() { static $initialized = false;