GetRankingDisabled   A
last analyzed

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 __invoke() 0 16 3
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VideoGamesRecords\CoreBundle\Controller\Chart\Player;
6
7
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8
use VideoGamesRecords\CoreBundle\DataProvider\Ranking\Player\PlayerChartRankingProvider;
0 ignored issues
show
Bug introduced by
The type VideoGamesRecords\CoreBu...yerChartRankingProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use VideoGamesRecords\CoreBundle\Entity\Chart;
10
use VideoGamesRecords\CoreBundle\Tools\Score;
11
12
class GetRankingDisabled extends AbstractController
13
{
14
    private PlayerChartRankingProvider $playerChartRankingProvider;
15
16
    public function __construct(PlayerChartRankingProvider $playerChartRankingProvider)
17
    {
18
        $this->playerChartRankingProvider = $playerChartRankingProvider;
19
    }
20
21
    /**
22
     * @param Chart    $chart
23
     * @return array
24
     */
25
    public function __invoke(Chart $chart): array
26
    {
27
        $ranking = $this->playerChartRankingProvider->getRankingDisabled($chart);
28
29
        for ($i = 0; $i <= count($ranking) - 1; $i++) {
30
            foreach ($chart->getLibs() as $lib) {
31
                $key = $lib->getId();
32
                // format value
33
                $ranking[$i]['values'][] = Score::formatScore(
34
                    $ranking[$i]["value_$key"],
35
                    $lib->getType()->getMask()
36
                );
37
            }
38
        }
39
40
        return $ranking;
41
    }
42
}
43