src/Helpers/Console.php
public static function confirm($message, $default = false, $rejectIfNo = true)
    {
        $promptMessage = $message . ' (yes|no) :';
        $promptOptions = [
            'default' => $default ? 'yes' : 'no',
            'validator' => function($input, &$error) {
                $input = trim($input);
                $variants = ['yes', 'no', 'y', 'n'];
                foreach ($variants as $variant) {
                    if (!strcasecmp($input, $variant)) {
                        return true;
                    }
                }
                $error = "You must type 'yes' or 'no' (y|n)";
                return false;
            },
        ];
        return static::prompt($promptMessage, $promptOptions)->then(function($input) use ($default, $rejectIfNo) {
            $input = trim($input);

            if (!strcasecmp($input, 'y') || !strcasecmp($input, 'yes')) {
                return true;
            }

            if (!strcasecmp($input, 'n') || !strcasecmp($input, 'no')) {
                return $rejectIfNo ? reject(new Exception("User canceled")) : false;
            }

            return $default ? $default : ($rejectIfNo ? reject(new Exception("User canceled")) : false);
        });
    }
public static function confirm($message, $default = false, $rejectIfNo = true)
    {
        $promptMessage = $message . ' (yes|no) :';
        $promptOptions = [
            'default' => $default ? 'yes' : 'no',
            'validator' => function($input, &$error) {
                $input = trim($input);
                $variants = ['yes', 'no', 'y', 'n'];
                foreach ($variants as $variant) {
                    if (!strcasecmp($input, $variant)) {
                        return true;
                    }
                }
                $error = "You must type 'yes' or 'no' (y|n)";
                return false;
            },
        ];
        return static::prompt($promptMessage, $promptOptions)->then(function($input) use ($default, $rejectIfNo) {
            $input = trim($input);

            if (!strcasecmp($input, 'y') || !strcasecmp($input, 'yes')) {
                return true;
            }

            if (!strcasecmp($input, 'n') || !strcasecmp($input, 'no')) {
                return $rejectIfNo ? reject(new Exception("User canceled")) : false;
            }

            return $default ? $default : ($rejectIfNo ? reject(new Exception("User canceled")) : false);
        });
    }
Asks user to confirm by typing y or n.

A typical usage looks like the following:

```php
if (Console::confirm("Are you sure?")) {
echo "user typed yes\n";
} else {
echo "user typed no\n";
}
```

@param string $message to print out before waiting for user input
@param bool   $default this value is returned if no selection is made.
@param bool   $rejectIfNo
@return ExtendedPromiseInterface with bool whether user confirmed