Passed
Push — develop ( f2b0b4...a1dd18 )
by BENARD
04:21
created

ProofInProgressProvider::loadByGame()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 15
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\DataProvider;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
use VideoGamesRecords\CoreBundle\ValueObject\ProofStatus;
7
8
class ProofInProgressProvider
9
{
10
    private EntityManagerInterface $em;
11
12
    public function __construct(EntityManagerInterface $em)
13
    {
14
        $this->em = $em;
15
    }
16
17
    /**
18
     * @return float|int|mixed|string
19
     */
20
    public function loadByGame(): mixed
21
    {
22
        $query = $this->em->createQueryBuilder()
23
            ->from('VideoGamesRecords\CoreBundle\Entity\Game', 'gam')
24
            ->select('gam')
25
            ->addSelect('COUNT(proof) as nb')
26
            ->innerJoin('gam.groups', 'grp')
27
            ->innerJoin('grp.charts', 'chr')
28
            ->innerJoin('chr.proofs', 'proof')
29
            ->where('proof.status = :status')
30
            ->setParameter('status', ProofStatus::STATUS_IN_PROGRESS)
31
            ->groupBy('gam.id')
32
            ->orderBy('nb', 'DESC');
33
34
        return $query->getQuery()->getResult();
35
    }
36
}
37