/** * Determine the preferred content type for the current request * * @param ServerRequestInterface $request * * @return string */ private function type(ServerRequestInterface $request) { $accept = $request->getHeaderLine('Accept'); $priorities = $this->preferences->toArray(); if (!empty($accept)) { $preferred = $this->negotiator->getBest($accept, array_keys($priorities)); } if (!empty($preferred)) { return $preferred->getValue(); } return key($priorities); }