Passed
Push — develop ( 066bfa...edcc78 )
by
unknown
50s queued 10s
created

GameController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 71
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A teamRankingMedals() 0 6 1
A listByLetter() 0 8 1
A playerRankingPoints() 0 6 1
A teamRankingPoints() 0 6 1
A playerRankingMedals() 0 6 1
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\Controller;
4
5
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
use Symfony\Component\HttpFoundation\Request;
8
use VideoGamesRecords\CoreBundle\Entity\Game;
9
10
/**
11
 * Class GameController
12
 */
13
class GameController extends Controller
14
{
15
16
    /**
17
     * @param Request $request
18
     * @return mixed
19
     */
20
    public function listByLetter(Request $request)
21
    {
22
        $letter = $request->query->get('letter', '0');
23
        $locale = $request->query->get('locale', 'en');
24
        $games = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Game')
25
            ->findWithLetter($letter, $locale)
26
            ->getResult();
27
        return $games;
28
    }
29
30
31
    /**
32
     * @param Game    $game
33
     * @param Request $request
34
     * @return mixed
35
     */
36
    public function playerRankingPoints(Game $game, Request $request)
37
    {
38
        $maxRank = $request->query->get('maxRank', 5);
39
        $idPlayer = $request->query->get('idPlayer', null);
40
        $ranking = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:PlayerGame')->getRankingPoints($game->getId(), $maxRank, $idPlayer);
41
        return $ranking;
42
    }
43
44
45
    /**
46
     * @param Game    $game
47
     * @param Request $request
48
     * @return mixed
49
     */
50
    public function playerRankingMedals(Game $game, Request $request)
51
    {
52
        $maxRank = $request->query->get('maxRank', 5);
53
        $idPlayer = $request->query->get('idPlayer', null);
54
        $ranking = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:PlayerGame')->getRankingMedals($game->getId(), $maxRank, $idPlayer);
55
        return $ranking;
56
    }
57
58
59
    /**
60
     * @param Game    $game
61
     * @param Request $request
62
     * @return mixed
63
     */
64
    public function teamRankingPoints(Game $game, Request $request)
65
    {
66
        $maxRank = $request->query->get('maxRank', 5);
67
        $idPlayer = $request->query->get('idPlayer', null);
68
        $ranking = $this->getDoctrine()->getRepository('VideoGamesRecordsTeamBundle:TeamGame')->getRankingPoints($game->getId(), $maxRank, $idPlayer);
69
        return $ranking;
70
    }
71
72
73
    /**
74
     * @param Game    $game
75
     * @param Request $request
76
     * @return mixed
77
     */
78
    public function teamRankingMedals(Game $game, Request $request)
79
    {
80
        $maxRank = $request->query->get('maxRank', 5);
81
        $idPlayer = $request->query->get('idPlayer', null);
82
        $ranking = $this->getDoctrine()->getRepository('VideoGamesRecordsTeamBundle:TeamGame')->getRankingMedals($game->getId(), $maxRank, $idPlayer);
83
        return $ranking;
84
    }
85
}
86