ForwardMessages::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 7
dl 0
loc 16
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 PHPTdGram\Schema;
10
11
/**
12
 * Forwards previously sent messages. Returns the forwarded messages in the same order as the message identifiers passed in message_ids. If a message can't be forwarded, null will be returned instead of the message.
13
 */
14
class ForwardMessages extends TdFunction
15
{
16
    public const TYPE_NAME = 'forwardMessages';
17
18
    /**
19
     * Identifier of the chat to which to forward messages.
20
     */
21
    protected int $chatId;
22
23
    /**
24
     * Identifier of the chat from which to forward messages.
25
     */
26
    protected int $fromChatId;
27
28
    /**
29
     * Identifiers of the messages to forward.
30
     *
31
     * @var int[]
32
     */
33
    protected array $messageIds;
34
35
    /**
36
     * Options to be used to send the messages.
37
     */
38
    protected SendMessageOptions $options;
39
40
    /**
41
     * True, if the messages should be grouped into an album after forwarding. For this to work, no more than 10 messages may be forwarded, and all of them must be photo or video messages.
42
     */
43
    protected bool $asAlbum;
44
45
    /**
46
     * True, if content of the messages needs to be copied without links to the original messages. Always true if the messages are forwarded to a secret chat.
47
     */
48
    protected bool $sendCopy;
49
50
    /**
51
     * True, if media captions of message copies needs to be removed. Ignored if send_copy is false.
52
     */
53
    protected bool $removeCaption;
54
55
    public function __construct(
56
        int $chatId,
57
        int $fromChatId,
58
        array $messageIds,
59
        SendMessageOptions $options,
60
        bool $asAlbum,
61
        bool $sendCopy,
62
        bool $removeCaption
63
    ) {
64
        $this->chatId        = $chatId;
65
        $this->fromChatId    = $fromChatId;
66
        $this->messageIds    = $messageIds;
67
        $this->options       = $options;
68
        $this->asAlbum       = $asAlbum;
69
        $this->sendCopy      = $sendCopy;
70
        $this->removeCaption = $removeCaption;
71
    }
72
73
    public static function fromArray(array $array): ForwardMessages
74
    {
75
        return new static(
76
            $array['chat_id'],
77
            $array['from_chat_id'],
78
            $array['message_ids'],
79
            TdSchemaRegistry::fromArray($array['options']),
80
            $array['as_album'],
81
            $array['send_copy'],
82
            $array['remove_caption'],
83
        );
84
    }
85
86
    public function typeSerialize(): array
87
    {
88
        return [
89
            '@type'          => static::TYPE_NAME,
90
            'chat_id'        => $this->chatId,
91
            'from_chat_id'   => $this->fromChatId,
92
            'message_ids'    => $this->messageIds,
93
            'options'        => $this->options->typeSerialize(),
94
            'as_album'       => $this->asAlbum,
95
            'send_copy'      => $this->sendCopy,
96
            'remove_caption' => $this->removeCaption,
97
        ];
98
    }
99
100
    public function getChatId(): int
101
    {
102
        return $this->chatId;
103
    }
104
105
    public function getFromChatId(): int
106
    {
107
        return $this->fromChatId;
108
    }
109
110
    public function getMessageIds(): array
111
    {
112
        return $this->messageIds;
113
    }
114
115
    public function getOptions(): SendMessageOptions
116
    {
117
        return $this->options;
118
    }
119
120
    public function getAsAlbum(): bool
121
    {
122
        return $this->asAlbum;
123
    }
124
125
    public function getSendCopy(): bool
126
    {
127
        return $this->sendCopy;
128
    }
129
130
    public function getRemoveCaption(): bool
131
    {
132
        return $this->removeCaption;
133
    }
134
}
135