Passed
Pull Request — master (#572)
by Dmitriy
01:31
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\PostCreate;
6
7
use App\Application\Blog\UseCase\Post\Create\Command;
8
use App\Application\Blog\UseCase\Post\Create\Handler;
9
use App\Infrastructure\IO\Http\Blog\PostCreate\Request\Request;
10
use App\Infrastructure\IO\Http\Blog\PostCreate\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\Post(
21
 *     tags={"blog"},
22
 *     path="/{locale}/blog/",
23
 *     summary="Creates a blog post",
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\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/BlogPostCreate"),
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->getTitle(),
57
            $request->getText(),
58
            $request->getStatus(),
59
            $request->getUser(),
60
        );
61
        $handler->handle($command);
62
63
        return $responseFactory->create();
64
    }
65
}
66