GetCommentsListController::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller\Comment;
6
7
use App\Entity\Article;
8
use App\Repository\CommentRepository;
9
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
10
use Symfony\Component\Routing\Annotation\Route;
11
12
/**
13
 * @Route("/api/articles/{slug}/comments", methods={"GET"}, name="api_comments_list")
14
 */
15
final class GetCommentsListController extends AbstractController
16
{
17
    private CommentRepository $commentRepository;
18
19 1
    public function __construct(CommentRepository $repository)
20
    {
21 1
        $this->commentRepository = $repository;
22
    }
23
24 1
    public function __invoke(Article $article): array
25
    {
26
        return [
27 1
            'comments' => $this->commentRepository->findBy(['article' => $article]),
28
        ];
29
    }
30
}
31