ListAction::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Http\Action\Post;
6
7
use App\Model\Post\PostRepository;
8
use HttpSoft\Basis\Response\PrepareJsonDataTrait;
9
use HttpSoft\Response\JsonResponse;
10
use Psr\Http\Message\ResponseInterface;
11
use Psr\Http\Message\ServerRequestInterface;
12
use Psr\Http\Server\RequestHandlerInterface;
13
14
final class ListAction implements RequestHandlerInterface
15
{
16
    use PrepareJsonDataTrait;
17
18
    /**
19
     * @var PostRepository
20
     */
21
    private PostRepository $posts;
22
23
    /**
24
     * @param PostRepository $posts
25
     */
26 2
    public function __construct(PostRepository $posts)
27
    {
28 2
        $this->posts = $posts;
29
    }
30
31
    /**
32
     * {@inheritDoc}
33
     */
34 2
    public function handle(ServerRequestInterface $request): ResponseInterface
35
    {
36 2
        return new JsonResponse($this->prepareJsonData($this->posts->findAll()));
37
    }
38
}
39