Test Setup Failed
Push — develop ( 01f508...e1be97 )
by Mattias
01:57
created

APIMessage::hasText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace TelegramBot;
4
5
/**
6
 * message from api
7
 */
8
class APIMessage
9
{
10
    private $data;
11
12
    public function __construct($data)
13
    {
14
        $this->data = $data;
15
    }
16
17
    public function getData()
18
    {
19
        return $this->data;
20
    }
21
22
    public function hasText()
23
    {
24
        return isset($this->data['message']['text']);
25
    }
26
27
    public function getText()
28
    {
29
        if (!$this->hasText()) {
30
            return null;
31
        }
32
        return $this->data['message']['text'];
33
    }
34
35
    public function getResponseData($responseText)
36
    {
37
        return [
38
      'chat_id' => $this->data['message']['chat']['id'],
39
      'reply_to_message_id' => $this->data['message']['message_id'],
40
      'text' => $responseText
41
    ];
42
    }
43
44
    public function getUpdateId()
45
    {
46
        return $this->data['update_id'];
47
    }
48
}
49