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

PlayerCountryRankingProvider::getRankingMedals()   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 2
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\Ranking\Provider\Player;
4
5
use VideoGamesRecords\CoreBundle\Ranking\Provider\AbstractRankingProvider;
6
7
class PlayerCountryRankingProvider extends AbstractRankingProvider
8
{
9
    /**
10
     * @param int|null $id
11
     * @param array    $options
12
     * @return array
13
     */
14
    public function getRankingPoints(int $id = null, array $options = []): array
15
    {
16
        $country = $this->em->getRepository('VideoGamesRecords\CoreBundle\Entity\Country')->find($id);
17
        if (null === $country) {
18
            return [];
19
        }
20
21
        $maxRank = $options['maxRank'] ?? null;
22
23
        $query = $this->em->createQueryBuilder('p')
0 ignored issues
show
Unused Code introduced by
The call to Doctrine\ORM\EntityManag...e::createQueryBuilder() has too many arguments starting with 'p'. ( Ignorable by Annotation )

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

23
        $query = $this->em->/** @scrutinizer ignore-call */ createQueryBuilder('p')

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
24
            ->select('p')
25
            ->from('VideoGamesRecords\CoreBundle\Entity\Player', 'p')
26
            ->where('(p.country = :country)')
27
            ->setParameter('country', $country)
28
            ->orderBy('p.rankCountry');
29
30
        if ($maxRank !== null) {
31
            $query->andWhere('p.rankCountry <= :maxRank')
32
                ->setParameter('maxRank', $maxRank);
33
        } else {
34
            $query->setMaxResults($maxRank);
35
        }
36
37
        return $query->getQuery()->getResult();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $query->getQuery()->getResult() could return the type integer which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
38
    }
39
40
    /**
41
     * @param int|null $id
42
     * @param array $options
43
     * @return array
44
     */
45
    public function getRankingMedals(int $id = null, array $options = []): array
46
    {
47
        return array();
48
    }
49
}
50