Passed
Push — master ( d346aa...fd2cec )
by Nicolas
04:54
created

GetCommentsListController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace App\Controller\Comment;
4
5
use App\Entity\Article;
6
use App\Repository\CommentRepository;
7
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
8
use Symfony\Component\Routing\Annotation\Route;
9
10
/**
11
 * @Route("/api/articles/{slug}/comments", name="api_comments_list")
12
 * @Method("GET")
13
 */
14
final class GetCommentsListController
15
{
16
    /**
17
     * @var CommentRepository
18
     */
19
    private $commentRepository;
20
21
    /**
22
     * @param CommentRepository $repository
23
     */
24 1
    public function __construct(CommentRepository $repository)
25
    {
26 1
        $this->commentRepository = $repository;
27 1
    }
28
29
    /**
30
     * @param Article $article
31
     *
32
     * @return array
33
     */
34 1
    public function __invoke(Article $article)
35
    {
36 1
        return ['comments' => $this->commentRepository->findBy(['article' => $article])];
37
    }
38
}
39