Completed
Push — master ( a8a6e5...b4d61a )
by Arne
04:19
created

ConsoleStyle::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Archivr\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
    public function __construct(InputInterface $input, OutputInterface $output)
13
    {
14
        parent::__construct($input, $output);
15
16
        $this->getFormatter()->setStyle('bold', new OutputFormatterStyle(null, null, ['bold']));
17
    }
18
19
    /**
20
     * Asks the same question multiple times returning the answers as an array.
21
     *
22
     * @param string $question
23
     * @param callable $validator
24
     * @return array
25
     */
26
    public function askMultiple(string $question, callable $validator = null): array
27
    {
28
        $answers = [];
29
30
        while ($answer = $this->ask($question, null, $validator)) {
31
32
            $answers[] = $answer;
33
        }
34
35
        return $answers;
36
    }
37
}
38