Symfony\Component\Console\Style\SymfonyStyle::choice PHP Method

choice() public method

public choice ( $question, array $choices, $default = null )
$choices array
    public function choice($question, array $choices, $default = null)
    {
        if (null !== $default) {
            $values = array_flip($choices);
            $default = $values[$default];
        }

        return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
    }

Usage Example

Exemplo n.º 1
0
 private function getStop($value, $question = 'Which station ?')
 {
     $stops = $this->cff->getStop($value, false);
     if ($stops[0]['value'] != $value) {
         $values = array_column($stops, 'value');
         $value = $this->io->choice($question, $values, $stops[0]['value']);
         $key = array_search($value, $values);
         return $stops[$key];
     }
     return $stops[0];
 }
All Usage Examples Of Symfony\Component\Console\Style\SymfonyStyle::choice