Passed
Push — master ( 0b1636...daadce )
by Paweł
02:53
created

PlayerIO::newRound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 1
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 askForChoice(string $question, array $choices): mixed
25
    {
26
        return $this->io->choice($question, $choices);
27
    }
28
29
    public function askForInformation(string $question): string
30
    {
31
        return $this->io->ask($question);
32
    }
33
34
    public function askForConfirmation(string $question): bool
35
    {
36
        return $this->io->confirm($question);
37
    }
38
39
    public function tell(string|array $message): void
40
    {
41
        sleep(1);
42
        $this->io->text($message);
43
    }
44
45
    public function list(array $items): void
46
    {
47
        sleep(1);
48
        $this->io->definitionList(...$items);
49
    }
50
51
    public function newRound(string $message): void
52
    {
53
        sleep(1);
54
        $this->io->section($message);
55
    }
56
57
    public function note(string $message): void
58
    {
59
        $this->io->note($message);
60
    }
61
62
    private function clearOutput(): void
63
    {
64
        $this->io->write("\033\143");
65
    }
66
}
67