NewGameCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
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 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Infrastructure\Cli\Command;
6
7
use AardsGerds\Game\Event\Story\FirstChapter\WoodsTravel\WolfEncounter\WolfEncounterEvent;
8
use AardsGerds\Game\Event\Story\Story;
9
use AardsGerds\Game\Infrastructure\Cli\PlayerIO;
10
use AardsGerds\Game\Infrastructure\Persistence\PlayerState;
11
use AardsGerds\Game\Player\Player;
12
use Symfony\Component\Console\Command\Command;
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
use Symfony\Component\Console\Style\SymfonyStyle;
16
17
final class NewGameCommand extends Command
18
{
19
    protected static $defaultName = 'game:new';
20
21 11
    public function __construct(
22
        private PlayerState $playerState,
23
    ) {
24 11
        parent::__construct();
25 11
    }
26
27 11
    protected function configure(): void
28
    {
29 11
        $this->setDescription('This command starts new game');
30 11
    }
31
32
    protected function execute(InputInterface $input, OutputInterface $output): int
33
    {
34
        $playerIO = new PlayerIO(new SymfonyStyle($input, $output), $this->playerState);
35
        $player = Player::new($playerIO->askForInformation('Choose player name'));
36
37
        Story::continue(new WolfEncounterEvent(), $player, $playerIO);
38
39
        return Command::SUCCESS;
40
    }
41
}
42