Passed
Push — develop ( c95ce3...d0c957 )
by BENARD
22:42 queued 19:38
created

GetHomeForums   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProjetNormandie\ForumBundle\Controller;
6
7
use Doctrine\DBAL\Exception;
8
use Doctrine\ORM\EntityManagerInterface;
9
use ProjetNormandie\ForumBundle\Handler\UserDataInitHandler;
10
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
11
12
class GetHomeForums extends AbstractController
13
{
14
    private UserDataInitHandler $userDataInitHandler;
15
    private EntityManagerInterface $em;
16
17
    public function __construct(UserDataInitHandler $userDataInitHandler, EntityManagerInterface $em)
18
    {
19
        $this->userDataInitHandler = $userDataInitHandler;
20
        $this->em = $em;
21
    }
22
23
    /**
24
     * @return mixed
25
     * @throws Exception
26
     */
27
    public function __invoke(): mixed
28
    {
29
        $this->userDataInitHandler->process($this->getUser());
30
31
        return $this->em->getRepository('ProjetNormandie\ForumBundle\Entity\Category')
32
            ->getHome($this->getUser())
33
            ->getResult();
34
    }
35
}
36