Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Execute the console command.
  5. *
  6. * @return mixed
  7. */
  8. public function handle()
  9. {
  10. // Get single Parameters
  11. $username = $this->argument('user');
  12. $difficulty = $this->option('difficulty');
  13.  
  14. // Get all
  15. $arguments = $this->arguments();
  16. $options = $this->options();
  17.  
  18. // Stop execution and ask a question
  19. $answer = $this->ask('What is your name?');
  20.  
  21. // Ask for sensitive information
  22. $password = $this->secret('What is the password?');
  23.  
  24. // Choices
  25. $name = $this->choice('What is your name?', ['Taylor', 'Dayle'], $default);
  26.  
  27. // Confirmation
  28.  
  29. if ($this->confirm('Is '.$name.' correct, do you wish to continue? [y|N]')) {
  30. //
  31. }
  32. }
  33.  
  34. /**
  35. * Execute the console command.
  36. *
  37. * @return mixed
  38. */
  39. public function handle()
  40. {
  41. $difficulty = $this->option('difficulty');
  42.  
  43. if(!$difficulty){
  44. $difficulty = 'easy';
  45. }
  46.  
  47. $this->line('Welcome '.$this->argument('user').", starting test in difficulty : ". $difficulty);
  48.  
  49. $questions = [
  50. 'easy' => [
  51. 'How old are you ?', "What is the name of your mother?",
  52. 'Do you have 3 parents ?','Do you like Javascript?',
  53. 'Do you know what is a JS promise?'
  54. ],
  55. 'hard' => [
  56. 'Why the sky is blue?', "Can a kangaroo jump higher than a house?",
  57. 'Do you think i am a bad father?','why the dinosaurs disappeared?',
  58. "why don't whales have gills?"
  59. ]
  60. ];
  61.  
  62. $questionsToAsk = $questions[$difficulty];
  63. $answers = [];
  64.  
  65. foreach($questionsToAsk as $question){
  66. $answer = $this->ask($question);
  67. array_push($answers,$answer);
  68. }
  69.  
  70. $this->info("Thanks for do the quiz in the console, your answers : ");
  71.  
  72. for($i = 0;$i <= (count($questionsToAsk) -1 );$i++){
  73. $this->line(($i + 1).') '. $answers[$i]);
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement