Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
20 | 3 | public function index() |
|
21 | { |
||
22 | 3 | $questions = $this->getQuestions(); |
|
23 | 3 | $stringUtility = new StringUtility(); |
|
24 | |||
25 | 3 | if (empty($questions)) { |
|
26 | 1 | return ''; |
|
27 | } |
||
28 | |||
29 | 2 | foreach ($questions as $question => $questionInfo) { |
|
30 | 2 | if ($stringUtility->findInString($question, $this->getSlackbot()->getListener()->getMessage())) { |
|
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 | |||
63 |