Back to AddUserCommand class

Method getStringFromOption

public string
getStringFromOption
(mixed $option, mixed $question)
Method to get a value from option
Parameters
  • string $option set the option name
  • string $question set the question if user enters no value to option
Returns
  • string
Since
  • 4.0.0

Method getStringFromOption - Source code

/**
 * Method to get a value from option
 *
 * @param   string  $option    set the option name
 * @param   string  $question  set the question if user enters no value to option
 *
 * @return  string
 *
 * @since   4.0.0
 */
public function getStringFromOption($option, $question) : string
{
    $answer = (string) $this->cliInput->getOption($option);
    while (!$answer) {
        if ($option === 'password') {
            $answer = (string) $this->ioStyle->askHidden($question);
        } else {
            $answer = (string) $this->ioStyle->ask($question);
        }
    }
    return $answer;
}