protected function getController()
{
$routes = method_exists($this->app, 'getRoutes') ? $this->app->getRoutes() : [];
$method = $this->getMethod();
$pathInfo = $this->getPathInfo();
if (isset($routes[$method . $pathInfo]['action']['uses'])) {
$controller = $routes[$method . $pathInfo]['action']['uses'];
} elseif (isset($routes[$method . $pathInfo]['action'][0])) {
$controller = $routes[$method . $pathInfo]['action'][0];
} else {
$controller = null;
}
if ($controller instanceof \Closure) {
$controller = 'anonymous function';
} elseif (is_object($controller)) {
$controller = 'instance of ' . get_class($controller);
} else {
if (!is_string($controller)) {
$controller = null;
}
}
return $controller;
}