private function preferred(ServerRequestInterface $request): RequestHandlerInterface
    {
        $negotiator = new Negotiator;
        $accept = $request->getHeaderLine('Accept', '*/*');
        $priorities = array_keys($this->handlers);

        $best = $negotiator->getBest($accept, $priorities);

        $mediatype = $best ? $best->getValue() : current($priorities);

        return $this->handlers[$mediatype];
    }
private function preferred(ServerRequestInterface $request): RequestHandlerInterface
    {
        $negotiator = new Negotiator;
        $accept = $request->getHeaderLine('Accept', '*/*');
        $priorities = array_keys($this->handlers);

        $best = $negotiator->getBest($accept, $priorities);

        $mediatype = $best ? $best->getValue() : current($priorities);

        return $this->handlers[$mediatype];
    }
private function preferred ( ServerRequestInterface $ request ) : RequestHandlerInterface { $ negotiator = new Negotiator ; $ accept = $ request -> getHeaderLine ( 'Accept' , '*/*' ) ; $ priorities = array_keys ( $ this -> handlers ) ; $ best = $ negotiator -> getBest ( $ accept , $ priorities ) ; $ mediatype = $ best ? $ best -> getValue ( ) : current ( $ priorities ) ; return $ this -> handlers [ $ mediatype ] ; }
Return the preferred request handler. Fallback to the first one when no
request handler matches the request accept header.

@param \Psr\Http\Message\ServerRequestInterface $request
@return \Psr\Http\Server\RequestHandlerInterface
Return the preferred request handler . Fallback to the first one when no request handler matches the request accept header .