1 <?php declare(strict_types=1);
3 namespace Cli\Services;
5 use Symfony\Component\Console\Question\ChoiceQuestion;
6 use Symfony\Component\Console\Helper\QuestionHelper;
7 use Symfony\Component\Console\Input\InputInterface;
8 use Symfony\Component\Console\Output\OutputInterface;
9 use Symfony\Component\Console\Question\ConfirmationQuestion;
11 class InteractiveConsole
13 public function __construct(
14 protected QuestionHelper $helper,
15 protected InputInterface $input,
16 protected OutputInterface $output,
20 public function confirm(string $text): bool
22 $question = new ConfirmationQuestion($text . " (y/n)\n", false);
23 return $this->helper->ask($this->input, $this->output, $question);
26 public function choice(string $question, array $answers)
28 $question = new ChoiceQuestion($question, $answers, $answers[0]);
29 return $this->helper->ask($this->input, $this->output, $question);