NewGameCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 54.55%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 3
b 0
f 0
dl 0
loc 23
ccs 6
cts 11
cp 0.5455
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 3 1
A execute() 0 8 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\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