TelegramAdapter::sendMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace TelegramHandler;
4
use Telegram\Bot\Api as TelegramBotApi;
5
6
/**
7
 * TelegramAdapter
8
 *
9
 * @author Renan Melo <[email protected]>
10
 * @author Rafael Nery <[email protected]>
11
 *
12
 * @see AbstractProcessingHandler
13
 */
14
class TelegramAdapter
15
{
16
17
  private $telegram;
18
19
  private $chat_id;
20
21
  public function __construct($token, $chatId)
22
  {
23
24
      $this->telegram = new TelegramBotApi($token);
25
      $this->chat_id  = $chatId;
26
      return $this;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
27
  }
28
29
  public function sendMessage($message)
30
  {
31
32
    return $this->telegram->sendMessage([
33
        'chat_id' => $this->chat_id,
34
        'text' => $message,
35
        'parse_mode' => 'HTML'
36
    ]);
37
  }
38
}
39