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

PlayerInput   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 4
c 1
b 0
f 0
dl 0
loc 19
ccs 0
cts 8
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A askForConfirmation() 0 3 1
A __construct() 0 3 1
A askForInformation() 0 3 1
A askForDecision() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Infrastructure\Cli;
6
7
use AardsGerds\Game\Event\Decision;
8
use AardsGerds\Game\Event\DecisionCollection;
9
use AardsGerds\Game\Player\PlayerAction;
10
use Symfony\Component\Console\Style\SymfonyStyle;
11
12
final class PlayerInput implements PlayerAction
13
{
14
    public function __construct(
15
        private SymfonyStyle $io,
16
    ) {}
17
18
    public function askForDecision(string $question, DecisionCollection $decisions): Decision
19
    {
20
        return $this->io->choice($question, $decisions->getItems());
21
    }
22
23
    public function askForInformation(string $question): int|string
24
    {
25
        return $this->io->ask($question);
26
    }
27
28
    public function askForConfirmation(string $question): bool
29
    {
30
        return $this->io->confirm($question);
31
    }
32
}
33