src/main/php/Console.php
public function confirm(string $message, string $default = null): bool
    {
        $result = null;
        while (null === $result) {
            $result = $this->prompt($message)->ifIsOneOf(['y', 'Y', 'n', 'N', '']);
            if ('' === $result) {
                $result = ((null !== $default) ? ($default) : (null));
            }
        }

        return strtolower($result) === 'y';
    }
public function confirm(string $message, string $default = null): bool
    {
        $result = null;
        while (null === $result) {
            $result = $this->prompt($message)->ifIsOneOf(['y', 'Y', 'n', 'N', '']);
            if ('' === $result) {
                $result = ((null !== $default) ? ($default) : (null));
            }
        }

        return strtolower($result) === 'y';
    }
public function confirm ( string $ message , string $ default = null ) : bool { $ result = null ; while ( null === $ result ) { $ result = $ this -> prompt ( $ message ) -> ifIsOneOf ( [ 'y' , 'Y' , 'n' , 'N' , '' ] ) ; if ( '' === $ result ) { $ result = ( ( null !== $ default ) ? ( $ default ) : ( null ) ) ; } } return strtolower ( $ result ) === 'y' ; }
ask the user to confirm something

Repeats the message until user enters <y> or <n> (case insensitive). In
case a default is given and the users enters nothing this default will
be used - if the default is <y> it will return <true>, and <false>
otherwise.

@api
@param   string  $message  message to show before requesting user input
@param   string  $default  default selection if user enters nothing
@return  bool
@since   2.1.0
ask the user to confirm something