ForumRepository   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 __construct() 0 3 1
A getParentData() 0 8 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