SendMessage::getChatId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This phpFile is auto-generated.
5
 */
6
7
declare(strict_types=1);
8
9
namespace AurimasNiekis\TdLibSchema;
10
11
/**
12
 * Sends a message. Returns the sent message.
13
 */
14
class SendMessage extends TdFunction
15
{
16
    public const TYPE_NAME = 'sendMessage';
17
18
    /**
19
     * Target chat.
20
     *
21
     * @var int
22
     */
23
    protected int $chatId;
24
25
    /**
26
     * Identifier of the message to reply to or 0.
27
     *
28
     * @var int
29
     */
30
    protected int $replyToMessageId;
31
32
    /**
33
     * Options to be used to send the message.
34
     *
35
     * @var SendMessageOptions
36
     */
37
    protected SendMessageOptions $options;
38
39
    /**
40
     * Markup for replying to the message; for bots only.
41
     *
42
     * @var ReplyMarkup
43
     */
44
    protected ReplyMarkup $replyMarkup;
45
46
    /**
47
     * The content of the message to be sent.
48
     *
49
     * @var InputMessageContent
50
     */
51
    protected InputMessageContent $inputMessageContent;
52
53
    public function __construct(
54
        int $chatId,
55
        int $replyToMessageId,
56
        SendMessageOptions $options,
57
        ReplyMarkup $replyMarkup,
58
        InputMessageContent $inputMessageContent
59
    ) {
60
        $this->chatId              = $chatId;
61
        $this->replyToMessageId    = $replyToMessageId;
62
        $this->options             = $options;
63
        $this->replyMarkup         = $replyMarkup;
64
        $this->inputMessageContent = $inputMessageContent;
65
    }
66
67
    public static function fromArray(array $array): SendMessage
68
    {
69
        return new static(
70
            $array['chat_id'],
71
            $array['reply_to_message_id'],
72
            TdSchemaRegistry::fromArray($array['options']),
73
            TdSchemaRegistry::fromArray($array['reply_markup']),
74
            TdSchemaRegistry::fromArray($array['input_message_content']),
75
        );
76
    }
77
78
    public function typeSerialize(): array
79
    {
80
        return [
81
            '@type'                 => static::TYPE_NAME,
82
            'chat_id'               => $this->chatId,
83
            'reply_to_message_id'   => $this->replyToMessageId,
84
            'options'               => $this->options->typeSerialize(),
85
            'reply_markup'          => $this->replyMarkup->typeSerialize(),
86
            'input_message_content' => $this->inputMessageContent->typeSerialize(),
87
        ];
88
    }
89
90
    public function getChatId(): int
91
    {
92
        return $this->chatId;
93
    }
94
95
    public function getReplyToMessageId(): int
96
    {
97
        return $this->replyToMessageId;
98
    }
99
100
    public function getOptions(): SendMessageOptions
101
    {
102
        return $this->options;
103
    }
104
105
    public function getReplyMarkup(): ReplyMarkup
106
    {
107
        return $this->replyMarkup;
108
    }
109
110
    public function getInputMessageContent(): InputMessageContent
111
    {
112
        return $this->inputMessageContent;
113
    }
114
}
115