Test Failed
Pull Request — master (#87)
by Dmitriy
02:46
created

Action   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 17
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\IO\Http\Auth\PostLogin;
6
7
use App\Application\User\Service\UserService;
0 ignored issues
show
Bug introduced by
The type App\Application\User\Service\UserService 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 App\Infrastructure\IO\Http\Auth\PostLogin\Request\Request;
0 ignored issues
show
Bug introduced by
The type App\Infrastructure\IO\Ht...stLogin\Request\Request 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
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\SecurityScheme(
20
 *     securityScheme="ApiKey",
21
 *     type="apiKey",
22
 *     in="header",
23
 *     name="X-Api-Key"
24
 * )
25
 *
26
 * @OA\Post(
27
 *     tags={"auth"},
28
 *     path="/auth/login",
29
 *     summary="Authenticate by params",
30
 *     description="",
31
 *     @OA\Response(
32
 *          response="200",
33
 *          description="Success",
34
 *          @OA\JsonContent(
35
 *              allOf={
36
 *                  @OA\Schema(ref="#/components/schemas/Response"),
37
 *                  @OA\Schema(
38
 *                      @OA\Property(
39
 *                          property="data",
40
 *                          type="object",
41
 *                          @OA\Property(property="token", format="string",
42
 *     example="uap4X5Bd7078lxIFvxAflcGAa5D95iSSZkNjg3XFrE2EBRBlbj"),
43
 *                      ),
44
 *                  ),
45
 *              },
46
 *          )
47
 *    ),
48
 *    @OA\Response(
49
 *          response="400",
50
 *          description="Bad request",
51
 *          @OA\JsonContent(ref="#/components/schemas/BadResponse")
52
 *     ),
53
 *     @OA\RequestBody(
54
 *          required=true,
55
 *          @OA\MediaType(
56
 *              mediaType="application/json",
57
 *              @OA\Schema(ref="#/components/schemas/LoginRequest"),
58
 *          ),
59
 *     ),
60
 * )
61
 */
62
final class Action
63
{
64
    public function __construct(
65
        private DataResponseFactoryInterface $responseFactory,
66
        private UserService $userService,
67
    ) {
68
    }
69
70
    public function __invoke(Request $request): ResponseInterface
71
    {
72
        $identity = $this->userService->login(
73
            $request->getLogin(),
74
            $request->getPassword()
75
        );
76
77
        return $this->responseFactory->createResponse([
78
            'token' => $identity->getToken(),
79
        ]);
80
    }
81
}
82