Orno\Route\Dispatcher::handleFound PHP Method

handleFound() protected method

Handle dispatching of a found route
protected handleFound ( string | Closure $handler, integer | Orno\Route\CustomStrategyInterface $strategy, array $vars ) : Orno\Http\ResponseInterface
$handler string | Closure
$strategy integer | Orno\Route\CustomStrategyInterface
$vars array
return Orno\Http\ResponseInterface
    protected function handleFound($handler, $strategy, array $vars)
    {
        if (is_null($this->getStrategy())) {
            $this->setStrategy($strategy);
        }
        $controller = null;
        // figure out what the controller is
        if ($handler instanceof \Closure || is_string($handler) && is_callable($handler)) {
            $controller = $handler;
        }
        if (is_string($handler) && strpos($handler, '::') !== false) {
            $controller = explode('::', $handler);
        }
        // if controller method wasn't specified, throw exception.
        if (!$controller) {
            throw new \RuntimeException('A class method must be provided as a controller. ClassName::methodName');
        }
        // handle getting of response based on strategy
        if (is_integer($strategy)) {
            switch ($strategy) {
                case RouteStrategyInterface::METHOD_ARGUMENT_STRATEGY:
                    $response = $this->handleMethodArgumentStrategy($controller, $vars);
                    break;
                case RouteStrategyInterface::URI_STRATEGY:
                    $response = $this->handleUriStrategy($controller, $vars);
                    break;
                case RouteStrategyInterface::RESTFUL_STRATEGY:
                    $response = $this->handleRestfulStrategy($controller, $vars);
                    break;
                case RouteStrategyInterface::REQUEST_RESPONSE_STRATEGY:
                default:
                    $response = $this->handleRequestResponseStrategy($controller, $vars);
                    break;
                    // @codeCoverageIgnoreStart
            }
            // @codeCoverageIgnoreEnd
            return $response;
        }
        // we must be using a custom strategy
        return $strategy->dispatch($controller, $vars);
    }