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

HelloConversation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 3
c 3
b 1
f 1
lcom 0
cbo 4
dl 0
loc 22
ccs 0
cts 12
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 16 3
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