Cake\Console\ConsoleIo::_getInput PHP Method

_getInput() protected method

Prompts the user for input, and returns it.
protected _getInput ( string $prompt, string | null $options, string | null $default ) : string
$prompt string Prompt text.
$options string | null String of options. Pass null to omit.
$default string | null Default input value. Pass null to omit.
return string Either the default value, or the user-provided input.
    protected function _getInput($prompt, $options, $default)
    {
        $optionsText = '';
        if (isset($options)) {
            $optionsText = " {$options} ";
        }
        $defaultText = '';
        if ($default !== null) {
            $defaultText = "[{$default}] ";
        }
        $this->_out->write('<question>' . $prompt . "</question>{$optionsText}\n{$defaultText}> ", 0);
        $result = $this->_in->read();
        $result = trim($result);
        if ($default !== null && ($result === '' || $result === null)) {
            return $default;
        }
        return $result;
    }