NewGameAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 22
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Game\Features\GamePlay;
6
7
use App\Game\Features\GamePlay\Authentication\PlayerFromTokenExtractor;
8
use App\Game\Features\GamePlay\Authentication\PlayerNotFoundInTokenStorageException;
9
use App\Game\Features\GamePlay\Crossword\Type;
10
use Twig\Environment;
0 ignored issues
show
Bug introduced by
The type Twig\Environment 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
12
final class NewGameAction
13
{
14
    private PlayerFromTokenExtractor $extractor;
15
16
    public function __construct(PlayerFromTokenExtractor $extractor)
17
    {
18
        $this->extractor = $extractor;
19
    }
20
21
    public function __invoke(GamePlay $game, Environment $twig): string
22
    {
23
        try {
24
            $playerDto = $this->extractor->player();
25
        } catch (PlayerNotFoundInTokenStorageException) {
26
            return 'Login session is over.';
27
        }
28
29
        $gameDto = $game->new('en', Type::byRole($playerDto->role()), $playerDto->level() * 3);
30
31
        return $twig->render('@game/play.html.twig', [
32
            'player' => $playerDto,
33
            'game' => $gameDto,
34
        ]);
35
    }
36
}
37