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

GetRankingDisabled   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 16 3
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