Test Failed
Pull Request — master (#87)
by Dmitriy
02:38
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\GetIndex;
6
7
use App\Application\Blog\UseCase\Post\GetPageList\Command;
8
use App\Application\Blog\UseCase\Post\GetPageList\Handler;
9
use App\Infrastructure\IO\Http\Blog\GetIndex\Request\Request;
10
use App\Infrastructure\IO\Http\Blog\GetIndex\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/",
23
 *     summary="Returns paginated blog posts",
24
 *     description="",
25
 *     @OA\Parameter(ref="#/components/parameters/BlogIndexRequest"),
26
 *     @OA\Response(
27
 *          response="200",
28
 *          description="Success",
29
 *          @OA\JsonContent(
30
 *              allOf={
31
 *                  @OA\Schema(ref="#/components/schemas/Response"),
32
 *                  @OA\Schema(
33
 *                      @OA\Property(
34
 *                          property="data",
35
 *                          type="object",
36
 *                          @OA\Property(
37
 *                              property="posts",
38
 *                              type="array",
39
 *                              @OA\Items(ref="#/components/schemas/BlogIndexPost")
40
 *                          ),
41
 *                          @OA\Property(
42
 *                              property="paginator",
43
 *                              type="object",
44
 *                              ref="#/components/schemas/Paginator"
45
 *                          ),
46
 *                      ),
47
 *                  ),
48
 *              },
49
 *          )
50
 *    ),
51
 * )
52
 */
53
final class Action
54
{
55
    public function __invoke(
56
        Request $request,
57
        Handler $handler,
58
        ResponseFactory $responseFactory,
59
    ): ResponseInterface {
60
        $command = new Command($request->getPage());
61
        $paginator = $handler->handle($command);
62
63
        return $responseFactory->create($paginator);
64
    }
65
}
66