BaseChooser::askQuestion()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Bex\Behat\ChooseTestsExtension\Chooser;
4
5
use Symfony\Component\Console\Helper\QuestionHelper;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Question\ChoiceQuestion;
9
10
abstract class BaseChooser
11
{
12
    /**
13
     * @var InputInterface
14
     */
15
    protected $input;
16
    
17
    /**
18
     * @var OutputInterface
19
     */
20
    protected $output;
21
22
    /**
23
     * @param InputInterface  $input
24
     * @param OutputInterface $output
25
     */
26
    public function __construct(InputInterface $input, OutputInterface $output)
27
    {
28
        $this->input = $input;
29
        $this->output = $output;
30
    }
31
32
    /**
33
     * Asks user question.
34
     *
35
     * @param string   $message
36
     * @param string[] $choices
37
     * @param string   $default
38
     *
39
     * @return string
40
     */
41
    protected function askQuestion($message, $choices, $default)
42
    {
43
        $this->output->writeln('');
44
        $helper = new QuestionHelper();
45
        $question = new ChoiceQuestion(' ' . $message . "\n", $choices, $default);
46
47
        return $helper->ask($this->input, $this->output, $question);
48
    }
49
50
    abstract public function execute();
51
}
52