Completed
Push — master ( 5edef7...e95395 )
by Mattias
02:05
created

APIMessage::getResponseData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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