public static function ask($question, $defaultValue = null, $secret = false)
    {
        $value = '';
        while (trim($value) == '') {
            self::writeln('');
            self::write(' ' . $question, 'info');
            if ($defaultValue !== null) {
                self::write(' [');
                self::write($defaultValue, 'comment');
                self::write(']');
            }
            self::writeln(':');
            if ($secret) {
                self::write(' > ');
                if (self::$testValue === null) {
                    // @codeCoverageIgnoreStart
                    system('stty -echo');
                    $value = trim(fgets(STDIN));
                    system('stty echo');
                    // @codeCoverageIgnoreEnd
                } else {
                    $value = self::$testValue;
                }
            } else {
                if (self::$testValue === null) {
                    // @codeCoverageIgnoreStart
                    $value = readline(' > ');
                    // @codeCoverageIgnoreEnd
                } else {
                    $value = self::$testValue;
                }
            }
            if (trim($value) == '') {
                // @codeCoverageIgnoreStart
                $value = $defaultValue;
                // @codeCoverageIgnoreEnd
            }
            if (trim($value) == '') {
                // @codeCoverageIgnoreStart
                self::writeln('');
                self::block('[ERROR] A value is required', 'error');
                // @codeCoverageIgnoreEnd
            }
            self::writeln('');
        }
        return trim($value);
    }
public static function ask($question, $defaultValue = null, $secret = false)
    {
        $value = '';
        while (trim($value) == '') {
            self::writeln('');
            self::write(' ' . $question, 'info');
            if ($defaultValue !== null) {
                self::write(' [');
                self::write($defaultValue, 'comment');
                self::write(']');
            }
            self::writeln(':');
            if ($secret) {
                self::write(' > ');
                if (self::$testValue === null) {
                    // @codeCoverageIgnoreStart
                    system('stty -echo');
                    $value = trim(fgets(STDIN));
                    system('stty echo');
                    // @codeCoverageIgnoreEnd
                } else {
                    $value = self::$testValue;
                }
            } else {
                if (self::$testValue === null) {
                    // @codeCoverageIgnoreStart
                    $value = readline(' > ');
                    // @codeCoverageIgnoreEnd
                } else {
                    $value = self::$testValue;
                }
            }
            if (trim($value) == '') {
                // @codeCoverageIgnoreStart
                $value = $defaultValue;
                // @codeCoverageIgnoreEnd
            }
            if (trim($value) == '') {
                // @codeCoverageIgnoreStart
                self::writeln('');
                self::block('[ERROR] A value is required', 'error');
                // @codeCoverageIgnoreEnd
            }
            self::writeln('');
        }
        return trim($value);
    }
public static function ask ( $ question , $ defaultValue = null , $ secret = false ) { $ value = '' ; while ( trim ( $ value ) == '' ) { self :: writeln ( '' ) ; self :: write ( ' ' . $ question , 'info' ) ; if ( $ defaultValue !== null ) { self :: write ( ' [' ) ; self :: write ( $ defaultValue , 'comment' ) ; self :: write ( ']' ) ; } self :: writeln ( ':' ) ; if ( $ secret ) { self :: write ( ' > ' ) ; if ( self :: $ testValue === null ) { // @codeCoverageIgnoreStart system ( 'stty -echo' ) ; $ value = trim ( fgets ( STDIN ) ) ; system ( 'stty echo' ) ; // @codeCoverageIgnoreEnd } else { $ value = self :: $ testValue ; } } else { if ( self :: $ testValue === null ) { // @codeCoverageIgnoreStart $ value = readline ( ' > ' ) ; // @codeCoverageIgnoreEnd } else { $ value = self :: $ testValue ; } } if ( trim ( $ value ) == '' ) { // @codeCoverageIgnoreStart $ value = $ defaultValue ; // @codeCoverageIgnoreEnd } if ( trim ( $ value ) == '' ) { // @codeCoverageIgnoreStart self :: writeln ( '' ) ; self :: block ( '[ERROR] A value is required' , 'error' ) ; // @codeCoverageIgnoreEnd } self :: writeln ( '' ) ; } return trim ( $ value ) ; }
Ask question.

@param string $question
@param mixed $defaultValue Default null.
@param boolean $secret Default false.
@return string
Ask question .