public function dispatch(ServerRequestInterface $request, ResponseInterface $response)
    {

        $method = $request->getMethod();
        $uri = $request->getUri()->getPath();

        $d = new \FastRoute\Dispatcher\GroupCountBased($this->collector->getData());
        $r = $d->dispatch(
            ($method === 'HEAD' ? 'GET' : $method),
            $uri
        );

        switch ($r[0]) {
            case 0:
                throw new NotFoundException('Route not found');
                break;
            case 1:
                return call_user_func($r[1], $request, $response, $r[2]);
                break;
            case 2:
                throw new MethodNotAllowedException('Method not allowed', 0, null, $r[1]);
                break;
        }

        return $response;
    }
public function dispatch(ServerRequestInterface $request, ResponseInterface $response)
    {

        $method = $request->getMethod();
        $uri = $request->getUri()->getPath();

        $d = new \FastRoute\Dispatcher\GroupCountBased($this->collector->getData());
        $r = $d->dispatch(
            ($method === 'HEAD' ? 'GET' : $method),
            $uri
        );

        switch ($r[0]) {
            case 0:
                throw new NotFoundException('Route not found');
                break;
            case 1:
                return call_user_func($r[1], $request, $response, $r[2]);
                break;
            case 2:
                throw new MethodNotAllowedException('Method not allowed', 0, null, $r[1]);
                break;
        }

        return $response;
    }
public function dispatch ( ServerRequestInterface $ request , ResponseInterface $ response ) { $ method = $ request -> getMethod ( ) ; $ uri = $ request -> getUri ( ) -> getPath ( ) ; $ d = new \ FastRoute \ Dispatcher \ GroupCountBased ( $ this -> collector -> getData ( ) ) ; $ r = $ d -> dispatch ( ( $ method === 'HEAD' ? 'GET' : $ method ) , $ uri ) ; switch ( $ r [ 0 ] ) { case 0 : throw new NotFoundException ( 'Route not found' ) ; break ; case 1 : return call_user_func ( $ r [ 1 ] , $ request , $ response , $ r [ 2 ] ) ; break ; case 2 : throw new MethodNotAllowedException ( 'Method not allowed' , 0 , null , $ r [ 1 ] ) ; break ; } return $ response ; }
Performs the route matching and invokes the handler for the route, if
there is an error it throws exception.

@param ServerRequestInterface $request
@param ResponseInterface $response

@throws MethodNotAllowedException
@throws NotFoundException

@return ResponseInterface
Performs the route matching and invokes the handler for the route if there is an error it throws exception .