Passed
Push — master ( 35eebd...7b8a1a )
by Roman
16:45
created

src/Game/Application/Service/Auth/PlayerLogin.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Game\Application\Service\Auth;
6
7
use App\Game\Application\Exception\PlayerLoginException;
8
use App\Game\Domain\Repository\ReadPlayerRepositoryInterface;
9
use App\Game\Domain\Service\PlayerTokenHack;
10
use Psr\Log\LoggerInterface;
0 ignored issues
show
The type Psr\Log\LoggerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Throwable;
12
13
final class PlayerLogin
14
{
15
    private LoggerInterface $logger;
16
    private PlayerTokenHack $playerToken;
17
    private ReadPlayerRepositoryInterface $readPlayerRepository;
18
19
    public function __construct(
20
        LoggerInterface $logger,
21
        PlayerTokenHack $playerToken,
22
        ReadPlayerRepositoryInterface $readPlayerRepository
23
    ) {
24
        $this->logger = $logger;
25
        $this->playerToken = $playerToken;
26
        $this->readPlayerRepository = $readPlayerRepository;
27
    }
28
29
    /**
30
     * @throws PlayerLoginException
31
     */
32 2
    public function __invoke(string $nickname, string $password): void
33
    {
34
        try {
35 2
            $playerDto = $this->readPlayerRepository->findPlayerByNicknameAndPassword($nickname, $password);
36 1
            $this->playerToken->refresh($playerDto);
37
38 1
            return;
39 1
        } catch (Throwable $exception) {
40 1
            $this->logger->error($exception->getMessage());
41
        }
42
43 1
        throw new PlayerLoginException();
44
    }
45
}
46