Passed
Push — develop ( 398719...d50203 )
by BENARD
05:23
created

GetStats   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
dl 0
loc 26
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 13 1
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\Controller\Player\PlayerChart;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7
use VideoGamesRecords\CoreBundle\Entity\Player;
8
9
class GetStats extends AbstractController
10
{
11
    protected EntityManagerInterface $em;
12
13
    public function __construct(EntityManagerInterface $em)
14
    {
15
        $this->em = $em;
16
    }
17
18
    /**
19
     * @param Player $player
20
     * @return mixed
21
     */
22
    public function __invoke(Player $player): mixed
23
    {
24
         $query = $this->em->createQuery("
25
            SELECT
26
                 s,
27
                 COUNT(pc) as nb
28
            FROM VideoGamesRecords\CoreBundle\Entity\PlayerChartStatus s
29
            JOIN s.playerCharts pc
30
            WHERE pc.player = :player
31
            GROUP BY s.id");
32
33
        $query->setParameter('player', $player);
34
        return $query->getResult();
35
    }
36
}
37