AuthenticationEntryPoint   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A start() 0 12 2
1
<?php
2
namespace PhpDraft\Config\Security;
3
4
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\Security\Core\Exception\AuthenticationException;
7
8
class AuthenticationEntryPoint implements AuthenticationEntryPointInterface {
9
  /**
10
   * Starts the authentication scheme.
11
   *
12
   * @param Request $request The request that resulted in an AuthenticationException
13
   * @param AuthenticationException $authException The exception that started the authentication process
14
   *
15
   * @return Response
16
   */
17
  public function start(Request $request, AuthenticationException $authException = null)
18
  {
19
      $array = array('success' => false);
20
      
21
      if ($authException) {
22
        $array['error'] = $authException;
23
      }
24
25
      $response = new Response(json_encode($array), 401);
0 ignored issues
show
Bug introduced by
The type PhpDraft\Config\Security\Response was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
      $response->headers->set('Content-Type', 'application/json');
27
28
      return $response;
29
  }
30
}