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

Action::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
nc 1
nop 3
dl 0
loc 14
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\IO\Http\Blog\PutUpdate;
6
7
use App\Application\Blog\UseCase\Post\Update\Command;
8
use App\Application\Blog\UseCase\Post\Update\Handler;
9
use App\Infrastructure\IO\Http\Blog\PutUpdate\Request\Request;
10
use App\Infrastructure\IO\Http\Blog\PutUpdate\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\Put(
21
 *     tags={"blog"},
22
 *     path="/blog/{id}",
23
 *     summary="Updates a blog post with a given ID",
24
 *     description="",
25
 *     security={{"ApiKey": {}}},
26
 *     @OA\Parameter(
27
 *          @OA\Schema(type="int", example="2"),
28
 *          in="path",
29
 *          name="id",
30
 *          parameter="id"
31
 *     ),
32
 *     @OA\Response(
33
 *          response="200",
34
 *          description="Success",
35
 *          @OA\JsonContent(
36
 *              ref="#/components/schemas/Response"
37
 *          )
38
 *    ),
39
 *     @OA\RequestBody(
40
 *          required=true,
41
 *          @OA\MediaType(
42
 *              mediaType="application/json",
43
 *              @OA\Schema(ref="#/components/schemas/BlogUpdateRequest"),
44
 *          ),
45
 *     )
46
 * )
47
 */
48
final class Action
49
{
50
    public function __invoke(
51
        Request $request,
52
        Handler $handler,
53
        ResponseFactory $responseFactory,
54
    ): ResponseInterface {
55
        $command = new Command(
56
            $request->getId(),
57
            $request->getTitle(),
58
            $request->getText(),
59
            $request->getStatus(),
60
        );
61
        $handler->handle($command);
62
63
        return $responseFactory->create();
64
    }
65
}
66