TopicRepository::getForumData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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