Skip to content

Instantly share code, notes, and snippets.

@harini-ua
Last active June 20, 2017 12:07
Show Gist options
  • Save harini-ua/ec861033ce55940fffc9fd682cc98d7b to your computer and use it in GitHub Desktop.
Save harini-ua/ec861033ce55940fffc9fd682cc98d7b to your computer and use it in GitHub Desktop.
<?php
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// Get single Parameters
$username = $this->argument('user');
$difficulty = $this->option('difficulty');
// Get all
$arguments = $this->arguments();
$options = $this->options();
// Stop execution and ask a question
$answer = $this->ask('What is your name?');
// Ask for sensitive information
$password = $this->secret('What is the password?');
// Choices
$name = $this->choice('What is your name?', ['Taylor', 'Dayle'], $default);
// Confirmation
if ($this->confirm('Is '.$name.' correct, do you wish to continue? [y|N]')) {
//
}
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$difficulty = $this->option('difficulty');
if(!$difficulty){
$difficulty = 'easy';
}
$this->line('Welcome '.$this->argument('user').", starting test in difficulty : ". $difficulty);
$questions = [
'easy' => [
'How old are you ?', "What is the name of your mother?",
'Do you have 3 parents ?','Do you like Javascript?',
'Do you know what is a JS promise?'
],
'hard' => [
'Why the sky is blue?', "Can a kangaroo jump higher than a house?",
'Do you think i am a bad father?','why the dinosaurs disappeared?',
"why don't whales have gills?"
]
];
$questionsToAsk = $questions[$difficulty];
$answers = [];
foreach($questionsToAsk as $question){
$answer = $this->ask($question);
array_push($answers,$answer);
}
$this->info("Thanks for do the quiz in the console, your answers : ");
for($i = 0;$i <= (count($questionsToAsk) -1 );$i++){
$this->line(($i + 1).') '. $answers[$i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment