ForumRepository::getParentData()   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
11
class ForumRepository extends ServiceEntityRepository
12
{
13
    public function __construct(ManagerRegistry $registry)
14
    {
15
        parent::__construct($registry, Forum::class);
16
    }
17
18
    public function getParentData($forum)
19
    {
20
         $query = $this->createQueryBuilder('f')
21
            ->select('SUM(f.nbTopic) as nbTopic,SUM(f.nbMessage) as nbMessage, MAX(f.lastMessage) as lastMessage')
22
            ->where('f.parent = :forum')
23
            ->setParameter('forum', $forum);
24
25
        return $query->getQuery()->getResult()[0];
26
    }
27
}
28