Completed
Push — master ( c79300...9eb332 )
by Arne
02:48
created

ConsoleStyle::getOutput()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Storeman\Cli;
4
5
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Style\SymfonyStyle;
9
10
class ConsoleStyle extends SymfonyStyle
11
{
12
    /**
13
     * @var InputInterface
14
     */
15
    protected $input;
16
17
    /**
18
     * @var OutputInterface
19
     */
20
    protected $output;
21
22
    public function __construct(InputInterface $input, OutputInterface $output)
23
    {
24
        parent::__construct($input, $output);
25
26
        $this->input = $input;
27
        $this->output = $output;
28
29
        $this->getFormatter()->setStyle('bold', new OutputFormatterStyle(null, null, ['bold']));
30
    }
31
32
    public function getInput(): InputInterface
33
    {
34
        return $this->input;
35
    }
36
37
    public function getOutput(): OutputInterface
38
    {
39
        return $this->output;
40
    }
41
42
    /**
43
     * Asks the same question multiple times returning the answers as an array.
44
     *
45
     * @param string $question
46
     * @param callable $validator
47
     * @return array
48
     */
49
    public function askMultiple(string $question, callable $validator = null): array
50
    {
51
        $answers = [];
52
53
        while ($answer = $this->ask($question, null, $validator)) {
54
55
            $answers[] = $answer;
56
        }
57
58
        return $answers;
59
    }
60
}
61