| Conditions | 5 |
| Paths | 4 |
| Total Lines | 31 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function getRankingPoints(int $id = null, array $options = []): array |
||
| 17 | { |
||
| 18 | $chart = $this->em->getRepository('VideoGamesRecords\CoreBundle\Entity\Chart')->find($id); |
||
| 19 | if (null === $chart) { |
||
| 20 | return []; |
||
| 21 | } |
||
| 22 | |||
| 23 | $maxRank = $options['maxRank'] ?? null; |
||
| 24 | $team = $this->getTeam(); |
||
| 25 | |||
| 26 | $query = $this->em->createQueryBuilder() |
||
| 27 | ->select('tc') |
||
| 28 | ->from('VideoGamesRecords\CoreBundle\Entity\TeamChart', 'tc') |
||
| 29 | ->join('tc.team', 't') |
||
| 30 | ->addSelect('t') |
||
| 31 | ->orderBy('tc.rankPointChart'); |
||
| 32 | |||
| 33 | $query->where('tc.chart = :chart') |
||
| 34 | ->setParameter('chart', $chart); |
||
| 35 | |||
| 36 | if (($maxRank !== null) && ($team !== null)) { |
||
| 37 | $query->andWhere('(tc.rankPointChart <= :maxRank OR tc.team = :team)') |
||
| 38 | ->setParameter('maxRank', $maxRank) |
||
| 39 | ->setParameter('team', $team); |
||
| 40 | } elseif ($maxRank !== null) { |
||
| 41 | $query->andWhere('tc.rankPointChart <= :maxRank') |
||
| 42 | ->setParameter('maxRank', $maxRank); |
||
| 43 | } else { |
||
| 44 | $query->setMaxResults(100); |
||
| 45 | } |
||
| 46 | return $query->getQuery()->getResult(); |
||
|
|
|||
| 47 | } |
||
| 59 |