public static function create(RequestInterface $request):Response {
		$negotiator = new Negotiator();
		$acceptHeader = $request->getHeaderLine("accept")
			?: self::DEFAULT_ACCEPT;
		$priorities = [
			"text/html; charset=UTF-8",
			"application/json",
			"application/xml;q=0.5",
		];

		static::$mediaType = $negotiator->getBest(
			$acceptHeader,
			$priorities
		);

		if(static::$mediaType) {
			$accept = static::$mediaType->getType();
		}
		else {
			$accept = $acceptHeader;
		}

		if(!isset(static::$responseClassLookup[$accept])) {
			throw new UnknownAcceptHeaderException($accept);
		}
		return new static::$responseClassLookup[$accept];
	}
public static function create(RequestInterface $request):Response {
		$negotiator = new Negotiator();
		$acceptHeader = $request->getHeaderLine("accept")
			?: self::DEFAULT_ACCEPT;
		$priorities = [
			"text/html; charset=UTF-8",
			"application/json",
			"application/xml;q=0.5",
		];

		static::$mediaType = $negotiator->getBest(
			$acceptHeader,
			$priorities
		);

		if(static::$mediaType) {
			$accept = static::$mediaType->getType();
		}
		else {
			$accept = $acceptHeader;
		}

		if(!isset(static::$responseClassLookup[$accept])) {
			throw new UnknownAcceptHeaderException($accept);
		}
		return new static::$responseClassLookup[$accept];
	}
public static function create ( RequestInterface $ request ) : Response { $ negotiator = new Negotiator ( ) ; $ acceptHeader = $ request -> getHeaderLine ( "accept" ) ? : self :: DEFAULT_ACCEPT ; $ priorities = [ "text/html; charset=UTF-8" , "application/json" , "application/xml;q=0.5" , ] ; static :: $ mediaType = $ negotiator -> getBest ( $ acceptHeader , $ priorities ) ; if ( static :: $ mediaType ) { $ accept = static :: $ mediaType -> getType ( ) ; } else { $ accept = $ acceptHeader ; } if ( ! isset ( static :: $ responseClassLookup [ $ accept ] ) ) { throw new UnknownAcceptHeaderException ( $ accept ) ; } return new static :: $ responseClassLookup [ $ accept ] ; }
A Response object is a PSR-7 compatible object that is created here from the current
Request. The type of Response that is returned is determined by the type of request.
@see http://www.php-fig.org/psr/psr-7
A Response object is a PSR - 7 compatible object that is created here from the current Request . The type of Response that is returned is determined by the type of request .