TopicRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 15
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getForumData() 0 8 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProjetNormandie\ForumBundle\Repository;
6
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Doctrine\Persistence\ManagerRegistry;
9
use ProjetNormandie\ForumBundle\Entity\Forum;
10
use ProjetNormandie\ForumBundle\Entity\Topic;
11
12
class TopicRepository extends ServiceEntityRepository
13
{
14
    public function __construct(ManagerRegistry $registry)
15
    {
16
        parent::__construct($registry, Topic::class);
17
    }
18
19
    public function getForumData(Forum $forum)
20
    {
21
         $query = $this->createQueryBuilder('t')
22
            ->select('SUM(t.nbMessage) as nbMessage, COUNT(t) as nbTopic, MAX(t.lastMessage) as lastMessage')
23
            ->where('t.forum = :forum')
24
            ->setParameter('forum', $forum);
25
26
        return $query->getQuery()->getResult()[0];
27
    }
28
}
29