Passed
Pull Request — master (#572)
by Dmitriy
01:33
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;
0 ignored issues
show
Bug introduced by
The type OpenApi\Annotations 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...
12
use Psr\Http\Message\ResponseInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Http\Message\ResponseInterface 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...
13
14
/**
15
 * @OA\Tag(
16
 *     name="blog",
17
 *     description="Blog"
18
 * )
19
 *
20
 * @OA\Put(
21
 *     tags={"blog"},
22
 *     path="/{locale}/blog/{id}",
23
 *     summary="Updates a blog post with a given ID",
24
 *     description="",
25
 *     security={{"ApiKey": {}}},
26
 *     @OA\Parameter(
27
 *          @OA\Schema(type="string", example="en"),
28
 *          in="path",
29
 *          name="locale",
30
 *          parameter="locale"
31
 *     ),
32
 *     @OA\Parameter(
33
 *          @OA\Schema(type="int", example="2"),
34
 *          in="path",
35
 *          name="id",
36
 *          parameter="id"
37
 *     ),
38
 *     @OA\Response(
39
 *          response="200",
40
 *          description="Success",
41
 *          @OA\JsonContent(
42
 *              ref="#/components/schemas/Response"
43
 *          )
44
 *    ),
45
 *     @OA\RequestBody(
46
 *          required=true,
47
 *          @OA\MediaType(
48
 *              mediaType="application/json",
49
 *              @OA\Schema(ref="#/components/schemas/BlogUpdateRequest"),
50
 *          ),
51
 *     )
52
 * )
53
 */
54
final class Action
55
{
56
    public function __invoke(
57
        Request $request,
58
        Handler $handler,
59
        ResponseFactory $responseFactory,
60
    ): ResponseInterface {
61
        $command = new Command(
62
            $request->getId(),
63
            $request->getTitle(),
64
            $request->getText(),
65
            $request->getStatus(),
66
        );
67
        $handler->handle($command);
68
69
        return $responseFactory->create();
70
    }
71
}
72