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

UpdateReceiver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handleUpdate() 0 5 1
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