Completed
Push — master ( df80f0...840f28 )
by Rafal
11s
created

UserRating::users()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\GameRating\Communication\Controller;
4
5
use App\GameRating\Business\GameRatingFacadeInterface;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
use Symfony\Component\Routing\Annotation\Route;
8
9
class UserRating extends Controller
10
{
11
    /**
12
     * @var GameRatingFacadeInterface
13
     */
14
    private $gameRatingFacade;
15
16
    /**
17
     * @param GameRatingFacadeInterface $gameRatingFacade
18
     */
19
    public function __construct(GameRatingFacadeInterface $gameRatingFacade)
20
    {
21
        $this->gameRatingFacade = $gameRatingFacade;
22
    }
23
24
    /**
25
     * @Route("/users/", name="game_rating_users")
26
     */
27
    public function users()
28
    {
29
        $userScoreWithPositions = $this->gameRatingFacade->getUserScoreWithPosition();
30
        return $this->render(
31
            'game_rating/user_rating/users.html.twig',
32
            [
33
                'userScoreWithPositions' => $userScoreWithPositions,
34
            ]
35
        );
36
    }
37
38
    /**
39
     * @Route("/myInfo/", name="game_rating_my_info")
40
     */
41
    public function myInfo()
42
    {
43
        $userScoreWithPositions = $this->gameRatingFacade->getUserScoreWithPosition();
44
        $myScoreWithPositions = false;
45
        $userId = $this->getUser()->getId();
46
        foreach ($userScoreWithPositions as $userScoreWithPosition) {
47
            if ($userScoreWithPosition->getUserScore()->getUser()->getId() === $userId) {
48
                $myScoreWithPositions = $userScoreWithPosition;
49
                break;
50
            }
51
        }
52
        return $this->render(
53
            'game_rating/user_rating/my_info.html.twig',
54
            [
55
                'myScoreWithPositions' => $myScoreWithPositions,
56
            ]
57
        );
58
    }
59
}