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(); |
|
|
|
|
71
|
|
|
|
72
|
|
|
$query = $this->em->createQueryBuilder() |
|
|
|
|
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
|
|
|
|
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.