From c564e3bd52e43b93dfbf3345efa869e12417f351 Mon Sep 17 00:00:00 2001 From: Maarten Date: Tue, 7 Jan 2020 10:06:26 +0100 Subject: [PATCH] Update abstract base controller class --- src/Runtime/Http/Controllers/Controller.php | 29 +++++++++++++++++-- .../Http/Controllers/ControllerExtractor.php | 12 -------- 2 files changed, 26 insertions(+), 15 deletions(-) delete mode 100644 src/Runtime/Http/Controllers/ControllerExtractor.php diff --git a/src/Runtime/Http/Controllers/Controller.php b/src/Runtime/Http/Controllers/Controller.php index f1990b8..0a8774a 100644 --- a/src/Runtime/Http/Controllers/Controller.php +++ b/src/Runtime/Http/Controllers/Controller.php @@ -2,10 +2,33 @@ namespace Runtime\Http\Controllers; -class Controller { +use BadMethodCallException; +use Runtime\Http\Response; - public function lol() { - return new ControllerExtractor(); +abstract class Controller { + + /** + * @param string $method + * @param array $parameters + * @return Response + */ + public function callAction($method, $parameters) + { + return call_user_func_array([$this, $method], $parameters); + } + + /** + * @param string $method + * @param array $parameters + * @return mixed + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + throw new BadMethodCallException(sprintf( + 'Method %s::%s does not exist.', static::class, $method + )); } } \ No newline at end of file diff --git a/src/Runtime/Http/Controllers/ControllerExtractor.php b/src/Runtime/Http/Controllers/ControllerExtractor.php deleted file mode 100644 index 234bfb1..0000000 --- a/src/Runtime/Http/Controllers/ControllerExtractor.php +++ /dev/null @@ -1,12 +0,0 @@ -