Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Core;
- class Request {
- private function __construct() {}
- public static function get(array $opts) {
- if (!isset($opts['controller'])) {
- throw new \Exception("Missing required key 'controller'");
- }
- $controller = new $opts['controller'];
- $action = empty($opts['action']) ? 'index' : $opts['action'];
- $args = empty($opts['args']) ? array() : $opts['args'];
- if (!method_exists($controller, $action)) {
- throw new \Exception("The action $action does not exists in class {$opts['controller']}");
- }
- return call_user_func_array(array($controller, $action), $args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement