Passed
Push — master ( db43e8...42566f )
by Paweł
02:54
created

LoadGameCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 53.85%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
c 1
b 0
f 0
dl 0
loc 26
ccs 7
cts 13
cp 0.5385
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 9 1
A configure() 0 5 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Infrastructure\Cli\Command;
6
7
use AardsGerds\Game\Infrastructure\Cli\PlayerInput;
8
use AardsGerds\Game\Infrastructure\Persistence\PlayerState;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputArgument;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use Symfony\Component\Console\Style\SymfonyStyle;
14
15
final class LoadGameCommand extends Command
16
{
17
    protected static $defaultName = 'game:load';
18
19 2
    public function __construct(
20
        private PlayerState $playerState,
21
    ) {
22 2
        parent::__construct();
23 2
    }
24
25 2
    protected function configure(): void
26
    {
27
        $this
28 2
            ->setDescription('This command loads existing game')
29 2
            ->addArgument('player', InputArgument::REQUIRED, 'Player to load');
30 2
    }
31
32
    protected function execute(InputInterface $input, OutputInterface $output): int
33
    {
34
        $playerName = $input->getArgument('player');
35
        assert(is_string($playerName));
36
37
        $player = $this->playerState->load($playerName);
0 ignored issues
show
Unused Code introduced by
The assignment to $player is dead and can be removed.
Loading history...
38
        $playerInput = new PlayerInput(new SymfonyStyle($input, $output));
0 ignored issues
show
Unused Code introduced by
The assignment to $playerInput is dead and can be removed.
Loading history...
39
40
        return Command::SUCCESS;
41
    }
42
}
43