/**
     * Get the authentication type list
     * Since Apigility 1.1
     *
     */
    public function authTypeAction()
    {
        $request = $this->getRequest();
        $version = $this->getVersion($request);

        switch ($version) {
            case 1:
                return new ApiProblemResponse(
                    new ApiProblem(406, 'This API is supported starting from version 2')
                );
            case 2:
                if ($request->getMethod() !== $request::METHOD_GET) {
                    $response = new ApiProblemResponse(
                        new ApiProblem(405, 'Only the method GET is allowed for this URI')
                    );
                    $response->getHeaders()->addHeaderLine('Allow', 'GET');
                    return $response;
                }

                return $this->createAdapterCollection();
            default:
                return new ApiProblemResponse(
                    new ApiProblem(406, 'The API version specified is not supported')
                );
        }
    }
 /**
  * Map the authentication adapter to a module
  * Since Apigility 1.1
  *
  * @param  Request $request
  * @return ViewModel|ApiProblemResponse
  */
 protected function mappingAuthentication(Request $request)
 {
     $module = $this->params('name', false);
     $version = $this->params()->fromQuery('version', false);
     switch ($request->getMethod()) {
         case $request::METHOD_GET:
             return $this->createAuthenticationMapResult($this->model->getAuthenticationMap($module, $version));
         case $request::METHOD_PUT:
             return $this->updateAuthenticationMap($this->bodyParams(), $module, $version);
         case $request::METHOD_DELETE:
             return $this->removeAuthenticationMap($module, $version);
         default:
             $response = new ApiProblemResponse(new ApiProblem(405, 'Only the methods GET, PUT, DELETE are allowed for this URI'));
             $response->getHeaders()->addHeaderLine('Allow', 'GET, PUT, DELETE');
             return $response;
     }
 }
 /**
  * Merge headers set on the application response into the API Problem response.
  *
  * @param HttpResponse       $applicationResponse
  * @param ApiProblemResponse $apiProblemResponse
  */
 protected function mergeHeaders(HttpResponse $applicationResponse, ApiProblemResponse $apiProblemResponse)
 {
     $apiProblemHeaders = $apiProblemResponse->getHeaders();
     foreach ($applicationResponse->getHeaders() as $header) {
         if ($apiProblemHeaders->has($header->getFieldName())) {
             continue;
         }
         $apiProblemHeaders->addHeader($header);
     }
 }
 /**
  * @group 14
  */
 public function testOverridesReasonPhraseIfStatusCodeIsUnknown()
 {
     $response = new ApiProblemResponse(new ApiProblem(7, 'Random error'));
     $this->assertContains('Internal Server Error', $response->getReasonPhrase());
 }