Completed
Push — master ( fe0508...11cb26 )
by Kirill
02:20
created

UpdateReceiver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Chrl\AppBundle\UpdateReceiver;
4
5
use Chrl\AppBundle\BuktopuhaBotApi;
6
use Chrl\AppBundle\Type\Update;
7
8
class UpdateReceiver implements UpdateReceiverInterface
9
{
10
11
    private $config;
12
    private $telegramBotApi;
13
14
    public function __construct(BuktopuhaBotApi $telegramBotApi, $config)
15
    {
16
        $this->telegramBotApi = $telegramBotApi;
17
        $this->config = $config;
18
    }
19
20
    public function handleUpdate(Update $update)
21
    {
22
        $message = json_decode(json_encode($update->message), true);
23
        $this->telegramBotApi->sendMessage($message['chat']['id'], 'Hello from '.$this->config['bot_name'].'!');
24
    }
25
}
26