private function createResponse($route): ?Response
    {
        $controller = $this->getRouteControllerInstance($route);
        if (!is_null($controller)) {
            $responseBefore = $controller->before();
            if ($responseBefore instanceof Response) {
                return $responseBefore;
            }
        }

        $values = $route['route']->getArguments($this->requestedUri);
        $this->loadRequestParameters($values);
        $callback = new Callback($route['callback']);
        $arguments = $this->getFunctionArguments($callback->getReflection(), array_values($values));
        $response = $callback->executeArray($arguments);

        if (!is_null($controller)) {
            $responseAfter = $controller->after($response);
            if ($responseAfter instanceof Response) {
                return $responseAfter;
            }
        }
        return $response;
    }
private function createResponse($route): ?Response
    {
        $controller = $this->getRouteControllerInstance($route);
        if (!is_null($controller)) {
            $responseBefore = $controller->before();
            if ($responseBefore instanceof Response) {
                return $responseBefore;
            }
        }

        $values = $route['route']->getArguments($this->requestedUri);
        $this->loadRequestParameters($values);
        $callback = new Callback($route['callback']);
        $arguments = $this->getFunctionArguments($callback->getReflection(), array_values($values));
        $response = $callback->executeArray($arguments);

        if (!is_null($controller)) {
            $responseAfter = $controller->after($response);
            if ($responseAfter instanceof Response) {
                return $responseAfter;
            }
        }
        return $response;
    }
private function createResponse ( $ route ) : ? Response { $ controller = $ this -> getRouteControllerInstance ( $ route ) ; if ( ! is_null ( $ controller ) ) { $ responseBefore = $ controller -> before ( ) ; if ( $ responseBefore instanceof Response ) { return $ responseBefore ; } } $ values = $ route [ 'route' ] -> getArguments ( $ this -> requestedUri ) ; $ this -> loadRequestParameters ( $ values ) ; $ callback = new Callback ( $ route [ 'callback' ] ) ; $ arguments = $ this -> getFunctionArguments ( $ callback -> getReflection ( ) , array_values ( $ values ) ) ; $ response = $ callback -> executeArray ( $ arguments ) ; if ( ! is_null ( $ controller ) ) { $ responseAfter = $ controller -> after ( $ response ) ; if ( $ responseAfter instanceof Response ) { return $ responseAfter ; } } return $ response ; }
Creates the response to return while executing the before and after
methods if they are available.

@param $route
@throws \Exception
@return Response | null
Creates the response to return while executing the before and after methods if they are available .