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

Action   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 11
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\IO\Http\Blog\GetView;
6
7
use App\Application\Blog\UseCase\Post\GetById\Command;
8
use App\Application\Blog\UseCase\Post\GetById\Handler;
9
use App\Infrastructure\IO\Http\Blog\GetView\Request\Request;
10
use App\Infrastructure\IO\Http\Blog\GetView\Response\ResponseFactory;
11
use OpenApi\Annotations as OA;
12
use Psr\Http\Message\ResponseInterface;
13
14
/**
15
 * @OA\Tag(
16
 *     name="blog",
17
 *     description="Blog"
18
 * )
19
 *
20
 * @OA\Get(
21
 *     tags={"blog"},
22
 *     path="/blog/{id}",
23
 *     summary="Returns a post with a given ID",
24
 *     description="",
25
 *     @OA\Parameter(
26
 *          @OA\Schema(type="int", example="2"),
27
 *          in="path",
28
 *          name="id",
29
 *          parameter="id"
30
 *     ),
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(
42
 *                              property="post",
43
 *                              type="object",
44
 *                              ref="#/components/schemas/BlogViewPost"
45
 *                          ),
46
 *                      ),
47
 *                  ),
48
 *              },
49
 *          )
50
 *    ),
51
 *    @OA\Response(
52
 *          response="404",
53
 *          description="Not found",
54
 *          @OA\JsonContent(
55
 *              allOf={
56
 *                  @OA\Schema(ref="#/components/schemas/BadResponse"),
57
 *                  @OA\Schema(
58
 *                      @OA\Property(property="error_message", example="Entity not found"),
59
 *                      @OA\Property(property="error_code", nullable=true, example=404)
60
 *                  ),
61
 *              },
62
 *          )
63
 *    ),
64
 * )
65
 */
66
final class Action
67
{
68
    public function __invoke(
69
        Request $request,
70
        Handler $handler,
71
        ResponseFactory $responseFactory,
72
    ): ResponseInterface {
73
        $command = new Command($request->getId());
74
        $post = $handler->handle($command);
75
76
        return $responseFactory->create($post);
77
    }
78
}
79