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

ConsoleStyle   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A askMultiple() 0 11 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