Passed
Push — develop ( 7a0698...a02364 )
by BENARD
05:04
created

GetRankingDisabled::getRankingDisabled()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 16
rs 10
cc 3
nc 3
nop 1
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\Controller\Chart\Player;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
6
use VideoGamesRecords\CoreBundle\Ranking\Provider\Player\PlayerChartRankingProvider;
7
use VideoGamesRecords\CoreBundle\Entity\Chart;
8
use VideoGamesRecords\CoreBundle\Tools\Score;
9
10
class GetRankingDisabled extends AbstractController
11
{
12
    private PlayerChartRankingProvider $playerChartRankingProvider;
13
14
    public function __construct(PlayerChartRankingProvider $playerChartRankingProvider)
15
    {
16
        $this->playerChartRankingProvider = $playerChartRankingProvider;
17
    }
18
19
    /**
20
     * @param Chart    $chart
21
     * @return array
22
     */
23
    public function __invoke(Chart $chart): array
24
    {
25
        $ranking = $this->playerChartRankingProvider->getRankingDisabled($chart);
26
27
        for ($i = 0; $i <= count($ranking) - 1; $i++) {
28
            foreach ($chart->getLibs() as $lib) {
29
                $key = $lib->getIdLibChart();
30
                // format value
31
                $ranking[$i]['values'][] = Score::formatScore(
32
                    $ranking[$i]["value_$key"],
33
                    $lib->getType()->getMask()
34
                );
35
            }
36
        }
37
38
        return $ranking;
39
    }
40
}
41