Passed
Push — develop ( 743c4e...d8f86b )
by BENARD
08:44
created

ForumController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A readAll() 0 4 1
A readForum() 0 4 1
1
<?php
2
3
namespace ProjetNormandie\ForumBundle\Controller;
4
5
use Doctrine\DBAL\Exception;
6
use ProjetNormandie\ForumBundle\Service\MarkAsReadService;
7
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8
use Symfony\Component\HttpFoundation\JsonResponse;
9
use ProjetNormandie\ForumBundle\Entity\Forum;
10
11
/**
12
 * Class ForumController
13
 */
14
class ForumController extends AbstractController
15
{
16
    private MarkAsReadService $markAsReadService;
17
18
    public function __construct(MarkAsReadService $markAsReadService)
19
    {
20
        $this->markAsReadService = $markAsReadService;
21
    }
22
23
    /**
24
     * @return JsonResponse
25
     */
26
    public function readAll(): JsonResponse
27
    {
28
        $this->markAsReadService->readAll();
29
        return new JsonResponse(['sucess' => true]);
30
    }
31
32
33
34
    /**
35
     * @param Forum $forum
36
     * @return JsonResponse
37
     */
38
    public function readForum(Forum $forum): JsonResponse
39
    {
40
        $this->markAsReadService->readForum($forum);
41
        return new JsonResponse(['sucess' => true]);
42
    }
43
}
44