Passed
Push — develop ( cfccb6...0b3512 )
by BENARD
04:54
created

GetProfile   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 6 2
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\Controller\Player;
4
5
use Doctrine\ORM\NonUniqueResultException;
6
use Doctrine\ORM\ORMException;
7
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8
use VideoGamesRecords\CoreBundle\Entity\Player;
9
use VideoGamesRecords\CoreBundle\Repository\PlayerRepository;
10
11
class GetProfile extends AbstractController
12
{
13
    protected PlayerRepository $playerRepository;
14
15
    /**
16
     * @param PlayerRepository $playerRepository
17
     */
18
    public function __construct(PlayerRepository $playerRepository)
19
    {
20
        $this->playerRepository = $playerRepository;
21
    }
22
23
24
    /**
25
     * @return mixed|Player|null
26
     * @throws NonUniqueResultException
27
     * @throws ORMException
28
     */
29
    public function __invoke(): mixed
30
    {
31
        if ($this->getUser() !== null) {
32
            return $this->playerRepository->getPlayerFromUser($this->getUser());
33
        }
34
        return null;
35
    }
36
}
37