GetChats::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 4
dl 0
loc 6
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
 * Returns an ordered list of chats in a chat list. Chats are sorted by the pair (order, chat_id) in decreasing order. (For example, to get a list of chats from the beginning, the offset_order should be equal to a biggest signed 64-bit number 9223372036854775807 == 2^63 - 1). For optimal performance the number of returned chats is chosen by the library.
13
 */
14
class GetChats extends TdFunction
15
{
16
    public const TYPE_NAME = 'getChats';
17
18
    /**
19
     * The chat list in which to return chats.
20
     *
21
     * @var ChatList
22
     */
23
    protected ChatList $chatList;
24
25
    /**
26
     * Chat order to return chats from.
27
     *
28
     * @var string
29
     */
30
    protected string $offsetOrder;
31
32
    /**
33
     * Chat identifier to return chats from.
34
     *
35
     * @var int
36
     */
37
    protected int $offsetChatId;
38
39
    /**
40
     * The maximum number of chats to be returned. It is possible that fewer chats than the limit are returned even if the end of the list is not reached.
41
     *
42
     * @var int
43
     */
44
    protected int $limit;
45
46
    public function __construct(ChatList $chatList, string $offsetOrder, int $offsetChatId, int $limit)
47
    {
48
        $this->chatList     = $chatList;
49
        $this->offsetOrder  = $offsetOrder;
50
        $this->offsetChatId = $offsetChatId;
51
        $this->limit        = $limit;
52
    }
53
54
    public static function fromArray(array $array): GetChats
55
    {
56
        return new static(
57
            TdSchemaRegistry::fromArray($array['chat_list']),
58
            $array['offset_order'],
59
            $array['offset_chat_id'],
60
            $array['limit'],
61
        );
62
    }
63
64
    public function typeSerialize(): array
65
    {
66
        return [
67
            '@type'          => static::TYPE_NAME,
68
            'chat_list'      => $this->chatList->typeSerialize(),
69
            'offset_order'   => $this->offsetOrder,
70
            'offset_chat_id' => $this->offsetChatId,
71
            'limit'          => $this->limit,
72
        ];
73
    }
74
75
    public function getChatList(): ChatList
76
    {
77
        return $this->chatList;
78
    }
79
80
    public function getOffsetOrder(): string
81
    {
82
        return $this->offsetOrder;
83
    }
84
85
    public function getOffsetChatId(): int
86
    {
87
        return $this->offsetChatId;
88
    }
89
90
    public function getLimit(): int
91
    {
92
        return $this->limit;
93
    }
94
}
95