/**
  * @param \OAuth2\Grant\ResponseTypeSupportInterface[] $types
  * @param \OAuth2\Endpoint\Authorization               $authorization
  *
  * @throws \OAuth2\Exception\BaseExceptionInterface
  *
  * @return \OAuth2\Endpoint\ResponseModeInterface
  */
 public function getResponseMode(array $types, Authorization $authorization)
 {
     if (null !== $authorization->getResponseMode() && true === $this->getConfiguration()->get('allow_response_mode_parameter_in_authorization_request', false)) {
         // The client uses the response_mode parameter and the server allows it
         $mode = $authorization->getResponseMode();
     } elseif (null !== ($multiple = $this->getResponseModeIfMultipleResponseTypes($authorization->getResponseType()))) {
         // The response type contains multiple types defined by OpenID Connect Specification
         $mode = $multiple;
     } elseif (1 < count($types)) {
         // The response type contains multiple types but not defined by OpenID Connect Specification
         throw $this->getExceptionManager()->getException(ExceptionManagerInterface::INTERNAL_SERVER_ERROR, ExceptionManagerInterface::SERVER_ERROR, sprintf('The response mode "%s" is not supported.', $authorization->getResponseType()));
     } else {
         // The response type contains only one type
         $mode = $types[0]->getResponseMode();
     }
     if (!array_key_exists($mode, $this->response_modes)) {
         throw $this->getExceptionManager()->getException(ExceptionManagerInterface::INTERNAL_SERVER_ERROR, ExceptionManagerInterface::SERVER_ERROR, sprintf('Unable to retrieve response mode for response type "%s".', $authorization->getResponseType()));
     }
     return $this->response_modes[$mode];
 }