| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 3 | public function index() |
|
| 19 | { |
||
| 20 | 3 | $questions = $this->getQuestions(); |
|
| 21 | |||
| 22 | 3 | $stringUtility = new StringUtility(); |
|
| 23 | 3 | $text = $this->getSlackbot()->getListener()->getMessage(); |
|
| 24 | |||
| 25 | 3 | if (empty($questions)) { |
|
| 26 | 1 | return ''; |
|
| 27 | } |
||
| 28 | |||
| 29 | 2 | foreach ($questions as $question => $questionInfo) { |
|
| 30 | 2 | if ($stringUtility->findInString($question, $text)) { |
|
| 31 | // found - return random answer |
||
| 32 | 1 | $answers = $questionInfo['answers']; |
|
| 33 | |||
| 34 | 2 | return $answers[array_rand($answers)]; |
|
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | 1 | return ''; |
|
| 39 | } |
||
| 40 | |||
| 61 |