lithium\console\Command::in PHP Method

in() public method

Handles input. Will continue to loop until $options['quit'] or result is part of $options['choices'].
public in ( string $prompt = null, array $options = [] ) : string | boolean
$prompt string
$options array
return string | boolean Returns the result of the input data. If the input is equal to the `quit` option boolean `false` is returned.
    public function in($prompt = null, array $options = array())
    {
        $defaults = array('choices' => null, 'default' => null, 'quit' => 'q');
        $options += $defaults;
        $choices = null;
        if (is_array($options['choices'])) {
            $choices = '(' . implode('/', $options['choices']) . ')';
        }
        $default = $options['default'] ? "[{$options['default']}] " : '';
        do {
            $this->out("{$prompt} {$choices} \n {$default}> ", 0);
            $result = trim($this->request->input());
        } while (!empty($options['choices']) && !in_array($result, $options['choices'], true) && (empty($options['quit']) || $result !== $options['quit']) && (!$options['default'] || $result !== ''));
        if ($result == $options['quit']) {
            return false;
        }
        if ($options['default'] !== null && $result == '') {
            return $options['default'];
        }
        return $result;
    }