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

LoadGameCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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