GetCommentsListController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 13
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
A __construct() 0 3 1
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