src/Commander/MessageManager.php
public function confirm($question, $default = 'yes')
    {
        //Show required message
        echo "\n";
        echo "\t", $this->colorize($question." [$default] ", 'info'); echo " ";
        //Get user input
        $response = trim(fgets(STDIN));
        //Check if $response is yes or not
        if($response == 'yes' || $response == 'no')
        {
            //If is yes or not return the response
            return $response;
        }
        else if(empty($response))
        {
            //If response is empty return default value
            return $default;
        }
        else
        {
            //If not passed argument, repeat confirmation.
            $this->confirm($question, $default);
        }
    }
public function confirm($question, $default = 'yes')
    {
        //Show required message
        echo "\n";
        echo "\t", $this->colorize($question." [$default] ", 'info'); echo " ";
        //Get user input
        $response = trim(fgets(STDIN));
        //Check if $response is yes or not
        if($response == 'yes' || $response == 'no')
        {
            //If is yes or not return the response
            return $response;
        }
        else if(empty($response))
        {
            //If response is empty return default value
            return $default;
        }
        else
        {
            //If not passed argument, repeat confirmation.
            $this->confirm($question, $default);
        }
    }
public function confirm ( $ question , $ default = 'yes' ) { //Show required message echo "\n" ; echo "\t" , $ this -> colorize ( $ question . " [$default] " , 'info' ) ; echo " " ; //Get user input $ response = trim ( fgets ( STDIN ) ) ; //Check if $response is yes or not if ( $ response == 'yes' || $ response == 'no' ) { //If is yes or not return the response return $ response ; } else if ( empty ( $ response ) ) { //If response is empty return default value return $ default ; } else { //If not passed argument, repeat confirmation. $ this -> confirm ( $ question , $ default ) ; } }
Provide a ConfirmManager.

@param string $question
@return string
Provide a ConfirmManager .