Passed
Push — develop ( d38868...21087d )
by Mario
01:26
created

AnonymousController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Controller\Token;
4
5
use App\Security\Provider\AnonymousProvider;
6
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
0 ignored issues
show
Bug introduced by
The type Lexik\Bundle\JWTAuthenti...WTTokenManagerInterface 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...
7
use Symfony\Component\HttpFoundation\JsonResponse;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\JsonResponse 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...
8
use Symfony\Component\HttpFoundation\Response;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\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...
9
10
use Symfony\Component\Routing\Annotation\Route;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Routing\Annotation\Route 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...
11
12
/**
13
 * Class AnonymousController
14
 */
15
final class AnonymousController
16
{
17
    /**
18
     * @var \App\Security\Provider\AnonymousProvider
19
     */
20
    private $anonymousProvider;
21
22
    /**
23
     * @var \Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface
24
     */
25
    private $tokenManager;
26
27
    /**
28
     * Constructor
29
     *
30
     * @param \App\Security\Provider\AnonymousProvider $anonymousProvider
31
     * @param \Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface $tokenManager
32
     */
33
    public function __construct(AnonymousProvider $anonymousProvider, JWTTokenManagerInterface $tokenManager)
34
    {
35
        $this->anonymousProvider = $anonymousProvider;
36
        $this->tokenManager = $tokenManager;
37
    }
38
39
    /**
40
     * Token
41
     *
42
     * @Route(path="/auth/anonymous", methods={"POST"})
43
     */
44
    public function post()
45
    {
46
        $user = $this->anonymousProvider->loadUserByUsername('[email protected]');
47
        $token = $this->tokenManager->create($user);
48
49
        return new JsonResponse(['token' => $token], Response::HTTP_CREATED);
50
    }
51
}
52