| @@ 99-112 (lines=14) @@ | ||
| 96 | * @param OutputInterface $output |
|
| 97 | * @return string |
|
| 98 | */ |
|
| 99 | protected function askApiKey(InputInterface $input, OutputInterface $output) : string |
|
| 100 | { |
|
| 101 | $question = (new Question('Enter API key: ')) |
|
| 102 | ->setValidator(function ($answer) { |
|
| 103 | if (is_null($answer)) { |
|
| 104 | throw new \InvalidArgumentException("API key can't be null."); |
|
| 105 | } |
|
| 106 | ||
| 107 | return $answer; |
|
| 108 | }) |
|
| 109 | ->setMaxAttempts(2); |
|
| 110 | ||
| 111 | return $this->getHelper('question')->ask($input, $output, $question); |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * Ask for secret key. |
|
| @@ 121-134 (lines=14) @@ | ||
| 118 | * @param OutputInterface $output |
|
| 119 | * @return string |
|
| 120 | */ |
|
| 121 | protected function askSecretKey(InputInterface $input, OutputInterface $output) : string |
|
| 122 | { |
|
| 123 | $question = (new Question('Enter secret key: ')) |
|
| 124 | ->setValidator(function ($answer) { |
|
| 125 | if (is_null($answer)) { |
|
| 126 | throw new \InvalidArgumentException("Secret key can't be null."); |
|
| 127 | } |
|
| 128 | ||
| 129 | return $answer; |
|
| 130 | }) |
|
| 131 | ->setMaxAttempts(2); |
|
| 132 | ||
| 133 | return $this->getHelper('question')->ask($input, $output, $question); |
|
| 134 | } |
|
| 135 | ||
| 136 | /** |
|
| 137 | * Dump cache file of APIs list. |
|