Passed
Pull Request — master (#572)
by Dmitriy
02:20 queued 52s
created

Action::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 9
rs 10
c 1
b 0
f 0
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;
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\Get(
21
 *     tags={"blog"},
22
 *     path="/{locale}/blog/{id}",
23
 *     summary="Returns a post with a given ID",
24
 *     description="",
25
 *     @OA\Parameter(
26
 *          @OA\Schema(type="string", example="en"),
27
 *          in="path",
28
 *          name="locale",
29
 *          parameter="locale"
30
 *     ),
31
 *     @OA\Parameter(
32
 *          @OA\Schema(type="int", example="2"),
33
 *          in="path",
34
 *          name="id",
35
 *          parameter="id"
36
 *     ),
37
 *     @OA\Response(
38
 *          response="200",
39
 *          description="Success",
40
 *          @OA\JsonContent(
41
 *              allOf={
42
 *                  @OA\Schema(ref="#/components/schemas/Response"),
43
 *                  @OA\Schema(
44
 *                      @OA\Property(
45
 *                          property="data",
46
 *                          type="object",
47
 *                          @OA\Property(
48
 *                              property="post",
49
 *                              type="object",
50
 *                              ref="#/components/schemas/BlogViewPost"
51
 *                          ),
52
 *                      ),
53
 *                  ),
54
 *              },
55
 *          )
56
 *    ),
57
 *    @OA\Response(
58
 *          response="404",
59
 *          description="Not found",
60
 *          @OA\JsonContent(
61
 *              allOf={
62
 *                  @OA\Schema(ref="#/components/schemas/BadResponse"),
63
 *                  @OA\Schema(
64
 *                      @OA\Property(property="error_message", example="Entity not found"),
65
 *                      @OA\Property(property="error_code", nullable=true, example=404)
66
 *                  ),
67
 *              },
68
 *          )
69
 *    ),
70
 * )
71
 */
72
final class Action
73
{
74
    public function __invoke(
75
        Request $request,
76
        Handler $handler,
77
        ResponseFactory $responseFactory,
78
    ): ResponseInterface {
79
        $command = new Command($request->getId());
80
        $post = $handler->handle($command);
81
82
        return $responseFactory->create($post);
83
    }
84
}
85