Passed
Push — master ( 9137c7...d6bc1c )
by Paweł
03:29
created

PlayerIO::clearOutput()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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 PlayerIO implements PlayerAction
13
{
14
    public function __construct(
15
        private SymfonyStyle $io,
16
    ) {}
17
18
    public function askForDecision(string $question, DecisionCollection $decisions): Decision
19
    {
20
        $this->clearOutput();
21
        return $this->io->choice($question, $decisions->getItems());
22
    }
23
24
    public function askForInformation(string $question): string
25
    {
26
        $this->clearOutput();
27
        return $this->io->ask($question);
28
    }
29
30
    public function askForConfirmation(string $question): bool
31
    {
32
        $this->clearOutput();
33
        return $this->io->confirm($question);
34
    }
35
36
    public function note(string $message): void
37
    {
38
        $this->io->note($message);
39
    }
40
41
    private function clearOutput(): void
42
    {
43
        $this->io->write("\033\143");
44
    }
45
}
46