SendMessage   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 89
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getInputMessageContent() 0 3 1
A __construct() 0 12 1
A fromArray() 0 8 1
A getReplyToMessageId() 0 3 1
A getChatId() 0 3 1
A typeSerialize() 0 9 1
A getOptions() 0 3 1
A getReplyMarkup() 0 3 1
1
<?php
2
3
/**
4
 * This phpFile is auto-generated.
5
 */
6
7
declare(strict_types=1);
8
9
namespace PHPTdGram\Schema;
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
    protected int $chatId;
22
23
    /**
24
     * Identifier of the message to reply to or 0.
25
     */
26
    protected int $replyToMessageId;
27
28
    /**
29
     * Options to be used to send the message.
30
     */
31
    protected SendMessageOptions $options;
32
33
    /**
34
     * Markup for replying to the message; for bots only.
35
     */
36
    protected ReplyMarkup $replyMarkup;
37
38
    /**
39
     * The content of the message to be sent.
40
     */
41
    protected InputMessageContent $inputMessageContent;
42
43
    public function __construct(
44
        int $chatId,
45
        int $replyToMessageId,
46
        SendMessageOptions $options,
47
        ReplyMarkup $replyMarkup,
48
        InputMessageContent $inputMessageContent
49
    ) {
50
        $this->chatId              = $chatId;
51
        $this->replyToMessageId    = $replyToMessageId;
52
        $this->options             = $options;
53
        $this->replyMarkup         = $replyMarkup;
54
        $this->inputMessageContent = $inputMessageContent;
55
    }
56
57
    public static function fromArray(array $array): SendMessage
58
    {
59
        return new static(
60
            $array['chat_id'],
61
            $array['reply_to_message_id'],
62
            TdSchemaRegistry::fromArray($array['options']),
63
            TdSchemaRegistry::fromArray($array['reply_markup']),
64
            TdSchemaRegistry::fromArray($array['input_message_content']),
65
        );
66
    }
67
68
    public function typeSerialize(): array
69
    {
70
        return [
71
            '@type'                 => static::TYPE_NAME,
72
            'chat_id'               => $this->chatId,
73
            'reply_to_message_id'   => $this->replyToMessageId,
74
            'options'               => $this->options->typeSerialize(),
75
            'reply_markup'          => $this->replyMarkup->typeSerialize(),
76
            'input_message_content' => $this->inputMessageContent->typeSerialize(),
77
        ];
78
    }
79
80
    public function getChatId(): int
81
    {
82
        return $this->chatId;
83
    }
84
85
    public function getReplyToMessageId(): int
86
    {
87
        return $this->replyToMessageId;
88
    }
89
90
    public function getOptions(): SendMessageOptions
91
    {
92
        return $this->options;
93
    }
94
95
    public function getReplyMarkup(): ReplyMarkup
96
    {
97
        return $this->replyMarkup;
98
    }
99
100
    public function getInputMessageContent(): InputMessageContent
101
    {
102
        return $this->inputMessageContent;
103
    }
104
}
105