AuthController   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A login() 0 11 1
1
<?php
2
3
namespace App\Users\Controller;
4
5
use App\Controller\BaseController;
6
use App\Users\Request\AuthUserRequest;
7
use App\Users\Service\AuthService;
8
use Symfony\Component\HttpFoundation\JsonResponse;
9
use Symfony\Component\Routing\Annotation\Route;
10
11
class AuthController extends BaseController
12
{
13
    /**
14
     * Endpoint action to get Access Token for authentication.
15
     *
16
     * @Route("/api/auth/login", methods={"POST", "OPTIONS"});
17
     *
18
     * @param $authUserRequest AuthUserRequest
19
     * @param $authService AuthService
20
     *
21
     * @throws \LogicException
22
     * @throws \Symfony\Component\HttpKernel\Exception\HttpException
23
     *
24
     * @return JsonResponse
25
     */
26 4
    public function login(AuthUserRequest $authUserRequest, AuthService $authService)
27
    {
28 4
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_ANONYMOUSLY');
29
30 4
        $apiToken = $authService->getTokenByRequest($authUserRequest);
31
32 2
        return $this->response([
33 2
            'api_token' => $apiToken->getToken(),
34 2
            'user_id' => $apiToken->getUser()->getId(),
35
        ]);
36
    }
37
}
38