| Conditions | 3 |
| Paths | 1 |
| Total Lines | 20 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | public function askReason() |
||
| 30 | { |
||
| 31 | $question = Question::create("Huh - you woke me up. What do you need?") |
||
| 32 | ->fallback('Unable to ask question') |
||
| 33 | ->callbackId('ask_reason') |
||
| 34 | ->addButtons([ |
||
| 35 | Button::create('Tell a joke')->value('joke'), |
||
| 36 | Button::create('Give me a fancy quote')->value('quote'), |
||
| 37 | ]); |
||
| 38 | |||
| 39 | return $this->ask($question, function (Answer $answer) { |
||
| 40 | if (!$answer->isInteractiveMessageReply()) { |
||
| 41 | return; |
||
| 42 | } |
||
| 43 | |||
| 44 | $response = $answer->getValue() === 'joke' |
||
| 45 | ? Http::get('http://api.icndb.com/jokes/random')->json('value.joke') |
||
| 46 | : Inspiring::quote(); |
||
| 47 | |||
| 48 | $this->say($response); |
||
|
|
|||
| 49 | }); |
||
| 52 |