Completed
Pull Request — master (#171)
by
unknown
02:33
created

HelloConversation::handle()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 16
ccs 0
cts 12
cp 0
rs 9.4285
cc 3
eloc 10
nc 2
nop 0
crap 12
1
<?php
2
3
namespace Telegram\Bot\Conversations;
4
5
/**
6
 * Class HelloConversation
7
 */
8
class HelloConversation extends Conversation
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    public function handle()
14
    {
15
        $text = \strtolower($this->getUpdate()->getMessage()->getText());
16
17
        if ((strpos($text, 'hi') !== false) || (strpos($text, 'hello') !== false)) {
18
            $this->replyWithMessage(['text' => "Hi, {$this->getUpdate()->getMessage()->getFrom()->getFirstName()}!"]);
19
20
            $this
21
                ->getUpdate()
22
                ->getMessage()
23
                ->getFrom()
24
                ->setCurrentConversation(
25
                    LeaveMeAloneConversation::class
26
                );
27
        }
28
    }
29
}
30