GetFormData   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 15
c 1
b 0
f 0
dl 0
loc 29
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 21 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VideoGamesRecords\CoreBundle\Controller\Chart;
6
7
use Doctrine\ORM\Exception\ORMException;
8
use Symfony\Component\HttpFoundation\Request;
9
use VideoGamesRecords\CoreBundle\Entity\Chart;
10
use VideoGamesRecords\CoreBundle\Controller\AbtsractFormDataController;
11
12
/**
13
 * Call api for form submit scores
14
 * Return charts with the one relation player-chart of the connected user
15
 * If the user has not relation, a default relation is created
16
 */
17
class GetFormData extends AbtsractFormDataController
18
{
19
    /**
20
     * @param Chart   $chart
21
     * @param Request $request
22
     * @return mixed
23
     * @throws ORMException
24
     */
25
    public function __invoke(Chart $chart, Request $request): mixed
26
    {
27
        $this->game = $chart->getGroup()->getGame();
28
29
        $player = $this->userProvider->getPlayer();
30
        $page = 1;
31
        $itemsPerPage = 20;
32
        $locale = $request->getLocale();
33
        $search = array(
34
            'chart' => $chart,
35
        );
36
37
        $charts = $this->em->getRepository(Chart::class)->getList(
38
            $player,
39
            $page,
40
            $search,
41
            $locale,
42
            $itemsPerPage
43
        );
44
45
        return $this->setScores($charts, $player);
46
    }
47
}
48