Passed
Push — develop ( e920eb...9cd2fd )
by BENARD
05:00
created

TeamRankingProvider::getRankingPointGame()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\Ranking\Provider\Team;
4
5
use Doctrine\ORM\Exception\ORMException;
6
7
class TeamRankingProvider
8
{
9
    /**
10
     * @param array $options
11
     * @return array
12
     * @throws ORMException
13
     */
14
    public function getRankingPointChart(array $options = []): array
15
    {
16
        return $this->getRanking('rankPointChart', $options);
17
    }
18
19
    /**
20
     * @param array $options
21
     * @return array
22
     * @throws ORMException
23
     */
24
    public function getRankingPointGame(array $options = []): array
25
    {
26
        return $this->getRanking('rankPointGame', $options);
27
    }
28
29
30
    /**
31
     * @param array $options
32
     * @return array
33
     * @throws ORMException
34
     */
35
    public function getRankingMedals(array $options = []): array
36
    {
37
        return $this->getRanking('rankMedal', $options);
38
    }
39
40
    /**
41
     * @param array $options
42
     * @return array
43
     * @throws ORMException
44
     */
45
    public function getRankingBadge(array $options = []): array
46
    {
47
        return $this->getRanking('rankBadge', $options);
48
    }
49
50
    /**
51
     * @param array $options
52
     * @return array
53
     * @throws ORMException
54
     */
55
    public function getRankingCup(array $options = []): array
56
    {
57
        return $this->getRanking('rankCup', $options);
58
    }
59
60
61
    /**
62
     * @param string $column
63
     * @param array  $options
64
     * @return array
65
     * @throws ORMException
66
     */
67
    private function getRanking(string $column = 'rankPointChart', array $options = []): array
68
    {
69
        $maxRank = $options['maxRank'] ?? 100;
70
        $team = $this->getTeam();
0 ignored issues
show
Bug introduced by
The method getTeam() does not exist on VideoGamesRecords\CoreBu...eam\TeamRankingProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

70
        /** @scrutinizer ignore-call */ 
71
        $team = $this->getTeam();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
71
72
        $query = $this->em->createQueryBuilder()
0 ignored issues
show
Bug Best Practice introduced by
The property em does not exist on VideoGamesRecords\CoreBu...eam\TeamRankingProvider. Did you maybe forget to declare it?
Loading history...
73
            ->select('t')
74
            ->from('VideoGamesRecords\CoreBundle\Entity\Team', 't')
75
            ->where("t.$column IS NOT NULL")
76
            ->orderBy("t.$column");
77
78
        if ($team !== null) {
79
            $query->andWhere("(t.$column <= :maxRank OR t = :team)")
80
                ->setParameter('maxRank', $maxRank)
81
                ->setParameter('team', $team);
82
        } else {
83
            $query->andWhere("t.$column <= :maxRank")
84
                ->setParameter('maxRank', $maxRank);
85
        }
86
        return $query->getQuery()->getResult();
87
    }
88
}
89