Passed
Pull Request — master (#87)
by Dmitriy
02:45
created

Action   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 12
ccs 3
cts 3
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\IO\Http\Auth\PostLogout;
6
7
use App\Application\User\Service\UserService;
8
use App\Infrastructure\IO\Http\Auth\PostLogout\Request\Request;
9
use OpenApi\Annotations as OA;
10
use Psr\Http\Message\ResponseInterface;
11
use Yiisoft\DataResponse\DataResponseFactoryInterface;
12
13
/**
14
 * @OA\Tag(
15
 *     name="auth",
16
 *     description="Authentication"
17
 * )
18
 *
19
 * @OA\Post(
20
 *     tags={"auth"},
21
 *     path="/auth/logout",
22
 *     summary="Logout",
23
 *     description="",
24
 *     security={{"ApiKey": {}}},
25
 *     @OA\Response(
26
 *          response="200",
27
 *          description="Success",
28
 *          @OA\JsonContent(ref="#/components/schemas/Response")
29
 *    ),
30
 *    @OA\Response(
31
 *          response="400",
32
 *          description="Bad request",
33
 *          @OA\JsonContent(ref="#/components/schemas/BadResponse")
34
 *     ),
35
 * )
36
 */
37
final class Action
38
{
39
    public function __construct(
40
        private DataResponseFactoryInterface $responseFactory,
41
        private UserService $userService,
42
    ) {
43
    }
44
45 1
    public function __invoke(Request $request): ResponseInterface
46
    {
47 1
        $this->userService->logout($request->getUser());
48 1
        return $this->responseFactory->createResponse();
49
    }
50
}
51